#38 tif/targa/chead iGetString() memory leak

closed-accepted
None
5
2004-07-02
2003-08-10
Anonymous
No

The iGetString() function in il_states.c duplicates a
truncated version of a string value and returns it to the
calling function. The TIF, TARGA and CHEAD modules all
use the iGetString() function to retrieve the values of
parameters but never free the returned pointer,
resulting in a possible memory leak.

Furthermore, the TIF module uses the iGetString()
function to retrieve values that do not even exist!
Instead, il_states.c returns the
IL_PNG_DESCRIPTION_STRING value for all IL_TIF_*
values requested.

The solution to the memory leak issue for CHEAD is the
use of ilGetString() instead of iGetString(); ilGetString()
returns a pointer to the existing value instead of
duplicating it. If the TIF and TARGA support requires
strings to be truncated then those functions should free
the results of iGetString(); otherwise, they should use
the ilGetString() function.

The only other module that uses iGetString() is il_png.c,
and the PNG module frees the allocated strings
correctly. If libpng does not modify these strings then
ilGetString() can be used instead in this case as well
(eliminating the need to free the strings afterwards), in
which case the iGetString() function can be eliminated
all together.

- Marshall (marshall AT magpcss DOT com)

Discussion

  • Anonymous - 2004-07-02
    • assigned_to: nobody --> darkyojimbo
     
  • Anonymous - 2004-07-02

    Logged In: YES
    user_id=710897

    iGetString uses iClipString to fix the size of the string, that's why it is
    used, leaks will be fixed

     
  • Anonymous - 2004-07-02
    • status: open --> closed-accepted
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks