bugGNU nano - Bugs: bug #61331, small memory leak when an rc...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #61331: small memory leak when an rc option with an argument is specified twice

Submitted by:  Benno Schulenberg <bens>
Submitted on:  Mon 11 Oct 2021 02:58:06 PM UTC  
 
Severity:  2 - Minor Status:  Fixed
Assigned to:  Benno Schulenberg <bens> Open/Closed:  Open

Mon 11 Oct 2021 03:22:12 PM UTC, comment #2: 

Fixed in git, commit 42610db8, by freeing each of the options-with-an-argument before assigning to them.  (Freeing NULL is not a problem -- it is just a small waste of time, but... who uses these options anyway?)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 11 Oct 2021 03:05:22 PM UTC, comment #1: 

Bug exists since at least version 2.1.10.  Bug was found by compiling with -fsanitize=address and putting a second 'set matchbrackets' at the end of my ~/.nanorc to test something.

The bug is hardly relevant, as it is a one-time and tiny leak and does not grow and grow over time.  But... -fsanitize=address does not care about that and blares even about two lost bytes.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 11 Oct 2021 02:58:06 PM UTC, original submission:  

To reproduce, run:

echo 'set punct "."' >testrc
echo 'set punct ":;.,"' >>testrc
valgrind --leak-check=full src/nano -f testrc 2>TRAIL; cat TRAIL

Then type ^X to immediately exit from nano.
Result:

==6089== 2 bytes in 1 blocks are definitely lost in loss record 9 of 416
==6089==    at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==6089==    by 0x12E0A6: nmalloc (utils.c:289)
==6089==    by 0x12E20C: measured_copy (utils.c:331)
==6089==    by 0x12E24D: copy_of (utils.c:342)
==6089==    by 0x125734: parse_rcfile (rcfile.c:1602)
==6089==    by 0x125C5E: parse_one_nanorc (rcfile.c:1656)
==6089==    by 0x125DBA: do_rcfiles (rcfile.c:1684)
==6089==    by 0x1201C3: main (nano.c:2117)

The problem is that the second time that 'punct' is assigned to, the string from the earlier assignment is not freed first.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Submitted the item)
  •  

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

    Only logged-in users can vote.

     

     

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-10-14 bens Summarysome memory leaks when an rc option with an argument is specified twice => small memory leak when an rc option with an argument is specified twice
    2021-10-11 bens StatusNone => Fixed
        Assigned toNone => bens
    2021-10-11 bens Summarysome memory leaks when an rc option with argument is specified twice => some memory leaks when an rc option with an argument is specified twice

    Back to the top


    Powered by Savane 3.7