buglibiconv - Bugs: bug #39489, Resource leaks in...

 
 

bug #39489: Resource leaks in get_charset_aliases function in libcharset/lib/localcharset.c file

Submitter:  Prabhat Kanth <prabhatkanth>
Submitted:  Mon 15 Jul 2013 10:03:07 AM UTC
   
 
Category:  Other Severity:  3 - Normal
Item Group:  None Status:  Not a Bug
Privacy:  Public Assigned to:  haible
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 23 Nov 2016 11:34:29 PM UTC, comment #2: 

This is a duplicate of bug #36781.

Bruno Haible <haible>
Group administrator
Sat 01 Oct 2016 04:12:53 PM UTC, comment #1: 

The "resource leak" leaks a piece of memory, in the order of a filename (usually < 1000 bytes). Most importantly, it does it only once (because once 'charset_aliases' has been computed it does not get recomputed again). Or more exactly, in multithread situations with thread contention, you can actually have this leaks a very small number of times. The important point: The size of the leaked memory is BOUNDED. It won't cause an out-of-memory.

Not a bug. All programs and all libraries have the freedom to allocate a bounded amount of memory for their initializations.

The patch you provided probably works; but I don't like it because it introduces additional lines of code solely for the purpose of memory allocation bookkeeping.

Bruno Haible <haible>
Group administrator
Mon 15 Jul 2013 10:03:07 AM UTC, original submission:  

Resource leaks in get_charset_aliases function  in libcharset/lib/localcharset.c file

Cause:
"dir" is not free, if it is allocated by relocate() defined in file "lib/relocatable.c" .relocate() is using xmalloc and it's returning allocated memory to "dir". 

Solution:

1.we have declared a flag "mallocked_dir_flag" which is initially 0 which will check whether the value "dir" get from relocate() defined in file "lib/relocatable.c" is using xmalloc
2.We have defined "predefined_libdir" and initialised by "LIBDIR" as:
  const char * predefined_libdir="LIBDIR";

and "mallocked_dir_flag" is set to 1 if "dir" is not equal to "predefined_libdir" i.e. "LIBDIR".

3.If "mallocked_dir_flag" is 1 we free the "dir". 
 
For more clarification the respective patch has been attached

Prabhat Kanth <prabhatkanth>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #28586:  libiconv_memfix.patch added by prabhatkanth (1KiB - application/octet-stream - Resource leaks in libcharset/lib/localcharset.c file)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Posted a comment)
  • -email is unavailable- added by prabhatkanth (Submitted the item)
  • -email is unavailable- added by prabhatkanth
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-11-24 haible CategoryNone Other
    2016-10-01 haible StatusNone Not a Bug
        Assigned toNone haible
        Open/ClosedOpen Closed
    2013-07-15 prabhatkanth Attached File- Added libiconv_memfix.patch, #28586
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code