diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2015-03-17 10:37:23 -0700 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2015-03-17 10:37:23 -0700 |
commit | 4a95950f960869446b85659baccc0f7f5752ea40 (patch) | |
tree | 101ec8e838e8ee11512ca35f921b7f4a05112e94 | |
parent | f9c848f3caa8d97e948d74efd569ebdc419431b0 (diff) | |
download | xrdp-proprietary-4a95950f960869446b85659baccc0f7f5752ea40.tar.gz xrdp-proprietary-4a95950f960869446b85659baccc0f7f5752ea40.zip |
X11rdp: check for errors from shmem calls
-rw-r--r-- | xorg/X11R7.6/rdp/rdpup.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index f25b390a..b72848d2 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) static int g_use_shmem = 1; /* turns on or off */ -static int g_shmemid = 0; +static int g_shmemid = -1; static char *g_shmemptr = 0; static int g_shmem_lineBytes = 0; static RegionPtr g_shm_reg = 0; @@ -750,21 +750,35 @@ process_screen_size_msg(int width, int height, int bpp) if (g_shmemptr != 0) { shmdt(g_shmemptr); + g_shmemptr = 0; } bytes = g_rdpScreen.rdp_width * g_rdpScreen.rdp_height * g_rdpScreen.rdp_Bpp; g_shmemid = shmget(IPC_PRIVATE, bytes, IPC_CREAT | 0777); - g_shmemptr = shmat(g_shmemid, 0, 0); - shmctl(g_shmemid, IPC_RMID, NULL); - LLOGLN(0, ("process_screen_size_msg: g_shmemid %d g_shmemptr %p", - g_shmemid, g_shmemptr)); - g_shmem_lineBytes = g_rdpScreen.rdp_Bpp * g_rdpScreen.rdp_width; - - if (g_shm_reg != 0) + if (g_shmemid != -1) { - RegionDestroy(g_shm_reg); + g_shmemptr = shmat(g_shmemid, 0, 0); + if (g_shmemptr == (void *) -1) + { + LLOGLN(0, ("process_screen_size_msg: shmat failed for %d " + "bytes g_shmemid %d", bytes, g_shmemid)); + g_shmemptr = 0; + shmctl(g_shmemid, IPC_RMID, NULL); + g_shmemid = -1; + } + else + { + shmctl(g_shmemid, IPC_RMID, NULL); + } + LLOGLN(0, ("process_screen_size_msg: g_shmemid %d g_shmemptr %p", + g_shmemid, g_shmemptr)); + g_shmem_lineBytes = g_rdpScreen.rdp_Bpp * g_rdpScreen.rdp_width; + if (g_shm_reg != 0) + { + RegionDestroy(g_shm_reg); + } + g_shm_reg = RegionCreate(NullBox, 0); } - g_shm_reg = RegionCreate(NullBox, 0); } mmwidth = PixelToMM(width); |