> On 14/01/11 13:22, Denton Thomas wrote:
>
> > Agreed, setting to NULL at declaration is pointless! Line 546 is
> > fine.
> >
> > Also agreed that it is smart to check xim_styles before use, and to
> > set it to NULL after. The xlib doc does not specify whether XFree
> > will or won't set incoming values to NULL. Probably safer.
>
> Denton, I have pushed a variant of your patch into svn at r8278.
> Please check it and let us know how it looks.
> Ditto for anyone else who's listening of course!
>
> Cheers,
> --
> Ian
>
>
>

Thanks for adding the conditions/checks at each return statment, Ian.

I should have suggested removing a couple lines, however -

XFree() must happen at the end of fl_init_xim() whether or not the  if 
condition fails at 564, so the new/final XFree() call is basically replacing 
line 567. I suggest we cut the XFree() at 567 and keep the new check/free at 
the end.

New r8278 below.

Cheers -

DLT


===================================================================
--- 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,17 @@
      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);
     fl_xim_im = NULL;
   }
+  // if xim_styles is still allocated, free it now
+  if(xim_styles) XFree(xim_styles);
 }

 void fl_open_display() {


_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to