提交 79fd2e6c 编写于 作者: L littlee

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: NSean Chou <zhouyx@linux.vnet.ibm.com>
上级 cb7a5f5c
...@@ -540,6 +540,8 @@ XImage* X11SD_CreateSharedImage(X11SDOps *xsdo, ...@@ -540,6 +540,8 @@ XImage* X11SD_CreateSharedImage(X11SDOps *xsdo,
J2dRlsTraceLn1(J2D_TRACE_ERROR, J2dRlsTraceLn1(J2D_TRACE_ERROR,
"X11SD_SetupSharedSegment shmget has failed: %s", "X11SD_SetupSharedSegment shmget has failed: %s",
strerror(errno)); strerror(errno));
free((void *)shminfo);
XDestroyImage(img);
return NULL; return NULL;
} }
...@@ -549,6 +551,8 @@ XImage* X11SD_CreateSharedImage(X11SDOps *xsdo, ...@@ -549,6 +551,8 @@ XImage* X11SD_CreateSharedImage(X11SDOps *xsdo,
J2dRlsTraceLn1(J2D_TRACE_ERROR, J2dRlsTraceLn1(J2D_TRACE_ERROR,
"X11SD_SetupSharedSegment shmat has failed: %s", "X11SD_SetupSharedSegment shmat has failed: %s",
strerror(errno)); strerror(errno));
free((void *)shminfo);
XDestroyImage(img);
return NULL; return NULL;
} }
...@@ -569,6 +573,9 @@ XImage* X11SD_CreateSharedImage(X11SDOps *xsdo, ...@@ -569,6 +573,9 @@ XImage* X11SD_CreateSharedImage(X11SDOps *xsdo,
J2dRlsTraceLn1(J2D_TRACE_ERROR, J2dRlsTraceLn1(J2D_TRACE_ERROR,
"X11SD_SetupSharedSegment XShmAttach has failed: %s", "X11SD_SetupSharedSegment XShmAttach has failed: %s",
strerror(errno)); strerror(errno));
shmdt(shminfo->shmaddr);
free((void *)shminfo);
XDestroyImage(img);
return NULL; return NULL;
} }
...@@ -1344,13 +1351,10 @@ void X11SD_DisposeXImage(XImage * image) { ...@@ -1344,13 +1351,10 @@ void X11SD_DisposeXImage(XImage * image) {
#ifdef MITSHM #ifdef MITSHM
if (image->obdata != NULL) { if (image->obdata != NULL) {
X11SD_DropSharedSegment((XShmSegmentInfo*)image->obdata); X11SD_DropSharedSegment((XShmSegmentInfo*)image->obdata);
} else { image->obdata = NULL;
free(image->data);
} }
#else
free(image->data);
#endif /* MITSHM */ #endif /* MITSHM */
XFree(image); XDestroyImage(image);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册