# HG changeset patch # User littlee # Date 1331530216 -28800 # Node ID bdd7741e16de1985418b251e0d4ad51ba1719354 # Parent e070119aa56ee4dc5506c19d2c4d2eecab8ad429 7151427: Fix the potential memory leak in error handling code in X11SurfaceData.c Summary: Free the memory in the error handling code. Reviewed-by: prr, jgodinez, bae Contributed-by: Sean Chou diff -r e070119aa56e -r bdd7741e16de jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c --- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c Wed Jul 05 18:04:46 2017 +0200 +++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c Mon Mar 12 13:30:16 2012 +0800 @@ -540,6 +540,8 @@ J2dRlsTraceLn1(J2D_TRACE_ERROR, "X11SD_SetupSharedSegment shmget has failed: %s", strerror(errno)); + free((void *)shminfo); + XDestroyImage(img); return NULL; } @@ -549,6 +551,8 @@ J2dRlsTraceLn1(J2D_TRACE_ERROR, "X11SD_SetupSharedSegment shmat has failed: %s", strerror(errno)); + free((void *)shminfo); + XDestroyImage(img); return NULL; } @@ -569,6 +573,9 @@ J2dRlsTraceLn1(J2D_TRACE_ERROR, "X11SD_SetupSharedSegment XShmAttach has failed: %s", strerror(errno)); + shmdt(shminfo->shmaddr); + free((void *)shminfo); + XDestroyImage(img); return NULL; } @@ -1344,13 +1351,10 @@ #ifdef MITSHM if (image->obdata != NULL) { X11SD_DropSharedSegment((XShmSegmentInfo*)image->obdata); - } else { - free(image->data); + image->obdata = NULL; } -#else - free(image->data); #endif /* MITSHM */ - XFree(image); + XDestroyImage(image); } }