From d87cc866fc8e594f2ff31394be6b5ce225be6f39 Mon Sep 17 00:00:00 2001 From: Ian MacArthur Date: Fri, 14 Jan 2011 22:06:41 +0000 Subject: This is an attempt to resolve the potential leaks identified in fl_init_xim() by Denton Thomas. This is not quite the patch as he proposed it, but I *think* whay I have done is OK. Seems to be OK for me anyway... Needs testing by others of course! git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8278 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_x.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 1de3b3cf2..da8be0ee9 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -550,6 +550,8 @@ void fl_init_xim() &xim_styles, NULL, NULL); } else { Fl::warning("XOpenIM() failed\n"); + // if xim_styles is allocated, free it now + if(xim_styles) XFree(xim_styles); return; } @@ -559,14 +561,19 @@ void fl_init_xim() Fl::warning("No XIM style found\n"); XCloseIM(fl_xim_im); fl_xim_im = NULL; + // if xim_styles is allocated, free it now + if(xim_styles) XFree(xim_styles); return; } if (!fl_xim_ic) { Fl::warning("XCreateIC() failed\n"); XCloseIM(fl_xim_im); - XFree(xim_styles); + if(xim_styles) XFree(xim_styles); + xim_styles = NULL; // make sure we remember we have free'd xim_styles fl_xim_im = NULL; } + // if xim_styles is still allocated, free it now + if(xim_styles) XFree(xim_styles); } void fl_open_display() { -- cgit v1.2.3