FLTK logo

STR #3069

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Bugs & Features | Roadmap 1.3 | SVN ⇄ GIT ]

STR #3069

Application:FLTK Library
Status:1 - Closed w/Resolution
Priority:2 - Low, e.g. a documentation error or undocumented side-effect
Scope:2 - Specific to an operating system
Subsystem:X11
Summary:Fixed two memory leaks in Fl_x.cxx
Version:1.3.2
Created By:normvcr
Assigned To:AlbrechtS
Fix Version:1.3.3 (SVN: v10323)
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:


Name/Time/Date Filename/Size  
 
#1 normvcr
15:53 Apr 16, 2014
Fl_x.cxx
72k
 
 
#2 AlbrechtS
14:53 Sep 18, 2014
str_3069.patch
1k
 
     

Trouble Report Comments:


Name/Time/Date Text  
 
#1 normvcr
15:53 Apr 16, 2014
Platform: Fedora 19 x86.
Fixed two memory leaks:

371c371
<   int missing_count;
---
>   int missing_count = 0;
398a399,401
>
>   if( 0 < missing_count ) XFreeStringList( missing_list );
>

and

1545a1549,1551
>
>       //Do the free even if nitems=0
>       XFree( words );
 
 
#2 AlbrechtS
14:53 Sep 18, 2014
Thanks for the patch. I changed your code slightly and upload it with this post as str_3069.patch against svn r 10321.

The 2nd part of your patch is already fixed in svn. Our current code is:

        if ( words ) { XFree(words); words = 0; }

(words is initialized to 0 before calling get_xwinprop()). This should be correct and avoids freeing a null pointer.

I'm not an X11 expert, and I have a question to part 1:

I can see your point, and so I added this code after initializing missing_list with 0:

  // if (missing_count > 0) XFreeStringList(missing_list);
  if (missing_list) XFreeStringList(missing_list);

I commented out your code and used 'if (missing_list)' as the condition. Again, this should avoid freeing a null pointer.

But the question is: why use 'XFreeStringList()' to free the list? I did not even see a mention that the list should be free'd, although this sounds sensible. I checked this man page:
http://www.x.org/releases/current/doc/man/man3/XCreateFontSet.3.xhtml

Is this per convention, or where can I verify that this is the correct way to free the list?
 
 
#3 AlbrechtS
09:39 Sep 19, 2014
With a little (offline) help from Norman (the OP) I found the docs. Thanks, Norman.

After a little more research I found in:

http://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Creating_and_Freeing_a_Font_Set

"The returned XFontSet and missing charset list should be freed with XFreeFontSet and XFreeStringList, respectively. ..."
 
 
#4 AlbrechtS
09:41 Sep 19, 2014
Fixed in Subversion repository.

Thanks for the patch.
 
     

Return to Bugs & Features ]

 
 

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