7151427: Fix the potential memory leak in error handling code in X11SurfaceData.c

Free the memory in the error handling code.

Reviewed-by: prr, jgodinez, bae
This commit is contained in:
Sean Chou 2012-03-12 13:30:16 +08:00 committed by Charles Lee
parent 651770b5df
commit 0e1c5e521a

View File

@ -540,6 +540,8 @@ XImage* X11SD_CreateSharedImage(X11SDOps *xsdo,
J2dRlsTraceLn1(J2D_TRACE_ERROR,
"X11SD_SetupSharedSegment shmget has failed: %s",
strerror(errno));
free((void *)shminfo);
XDestroyImage(img);
return NULL;
}
@ -549,6 +551,8 @@ XImage* X11SD_CreateSharedImage(X11SDOps *xsdo,
J2dRlsTraceLn1(J2D_TRACE_ERROR,
"X11SD_SetupSharedSegment shmat has failed: %s",
strerror(errno));
free((void *)shminfo);
XDestroyImage(img);
return NULL;
}
@ -569,6 +573,9 @@ XImage* X11SD_CreateSharedImage(X11SDOps *xsdo,
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 @@ void X11SD_DisposeXImage(XImage * image) {
#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);
}
}