X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Flibaxwin4.so_src%2Fwm.cpp;h=cae79c719a824d9c8005fe683eca2a746c8774ab;hb=f8cde3fab5eb27ebacf9d76a7ac478a68a36a38b;hp=ee1895ea1f6967705a5837c95c85b555cb251055;hpb=10949658e20bd7b35f9ebe1d9354119d993e115b;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/libaxwin4.so_src/wm.cpp b/Usermode/Libraries/libaxwin4.so_src/wm.cpp index ee1895ea..cae79c71 100644 --- a/Usermode/Libraries/libaxwin4.so_src/wm.cpp +++ b/Usermode/Libraries/libaxwin4.so_src/wm.cpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace AxWin { @@ -22,7 +23,7 @@ extern "C" tAxWin4_Window *AxWin4_CreateWindow(const char *Name) { // Allocate a window ID ::std::lock_guard lock(glWindowList); - int id = ::std::find(gWindowList.begin(), gWindowList.end(), nullptr) - gWindowList.end(); + int id = ::std::find(gWindowList.begin(), gWindowList.end(), nullptr) - gWindowList.begin(); if( id >= MAX_WINDOW_ID ) { throw ::std::runtime_error("AxWin4_CreateWindow - Out of IDs (TODO: Better exception)"); } @@ -30,6 +31,7 @@ extern "C" tAxWin4_Window *AxWin4_CreateWindow(const char *Name) { gWindowList.push_back(nullptr); } + assert(gWindowList[id] == nullptr); // Create window structure locally tAxWin4_Window *ret = new tAxWin4_Window(); @@ -118,13 +120,19 @@ extern "C" void *AxWin4_GetWindowBuffer(tAxWin4_Window *Window) req.WriteU16(Window->m_id); CDeserialiser response = GetSyncReply(req, IPCMSG_GETWINBUF); - if( response.ReadU16() != Window->m_id ) + unsigned int rspwin = response.ReadU16(); + if( rspwin != Window->m_id ) { - + _SysDebug("AxWin4_GetWindowBuffer: GETWINBUF reply for different window (%u != %u)", rspwin, Window->m_id); + return NULL; } uint64_t handle = response.ReadU64(); Window->m_fd = _SysUnMarshalFD(handle); + if( Window->m_fd == -1 ) { + _SysDebug("AxWin4_GetWindowBuffer: Unable to unmarshal resultant FD (0x%llx)", handle); + return NULL; + } _SysDebug("AxWin4_GetWindowBuffer: %llx = %i", handle, Window->m_fd); }