[Library] r8278 - branches/branch-1.3/src

GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[Library] r8278 - branches/branch-1.3/src fltk-dev Jan 14, 2011 top right image
 
Author: ianmacarthur
Date: 2011-01-14 14:06:41 -0800 (Fri, 14 Jan 2011)
New Revision: 8278
Log:
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!



Modified:
   branches/branch-1.3/src/Fl_x.cxx

Modified: branches/branch-1.3/src/Fl_x.cxx
===================================================================
--- branches/branch-1.3/src/Fl_x.cxx	2011-01-14 11:48:18 UTC (rev 8277)
+++ branches/branch-1.3/src/Fl_x.cxx	2011-01-14 22:06:41 UTC (rev 8278)
@@ -550,6 +550,8 @@
                   &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 @@
      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() {

Direct Link to Message ]
 
bottom left image   bottom right image
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2021 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.