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

 
 

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

Submitted by:  Prabhat Kanth <prabhatkanth>
Submitted on:  Mon Jul 15 10:03:07 2013  
 
Category: OtherSeverity: 3 - Normal
Item Group: NoneStatus: Not a Bug
Privacy: PublicAssigned to: Bruno Haible <haible>
Open/Closed: Closed

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed Nov 23 23:34:29 2016, comment #2:

This is a duplicate of bug #36781.

Bruno Haible <haible>
Project AdministratorIn charge of this item.
Sat Oct 1 16:12:53 2016, 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>
Project AdministratorIn charge of this item.
Mon Jul 15 10:03:07 2013, 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 File(s):
   
   
Comment:
   

Attached Files
file #28586:  libiconv_memfix.patch added by prabhatkanth (1kB - 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
  • -unavailable- added by haible (Posted a comment)
  • -unavailable- added by prabhatkanth (Submitted the item)
  • -unavailable- added by prabhatkanth
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu Nov 24 00:38:54 2016haibleCategoryNone=>Other
    Sat Oct 1 16:12:53 2016haibleStatusNone=>Not a Bug
      Assigned toNone=>haible
      Open/ClosedOpen=>Closed
    Mon Jul 15 10:03:07 2013prabhatkanthAttached File-=>Added libiconv_memfix.patch, #28586
      Carbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup