bugGNU nano - Bugs: bug #62991, memory leak when a string bind...

 
 

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

bug #62991: memory leak when a string bind specifies an unknown menu

Submitter:  Benno Schulenberg <bens>
Submitted:  Wed 31 Aug 2022 07:31:54 AM UTC
   
 
Severity:  2 - Minor Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

Wed 31 Aug 2022 02:48:20 PM UTC, comment #2: 

Fixed in git, commit 97fa42c8, by moving the menu-checking fragment to before the function-checking fragment.

Benno Schulenberg <bens>
Group administrator
Wed 31 Aug 2022 02:40:33 PM UTC, comment #1: 

I had ordered the check for a valid menu name after the check for a valid function name, to have error messages go from left to right -- meaning that if an error was reported for somewhere in the line, that everything to the left of it was okay.  But that has not been fully the case since the beginning, as the absence of a menu name gets reported before an invalid function name.

So... take the easy path and group the menu checks together before the function check, so that there will not be any allocation that needs to be freed again when the menu name is invalid.

Benno Schulenberg <bens>
Group administrator
Wed 31 Aug 2022 07:31:54 AM UTC, original submission:  

To reproduce, run:

echo 'bind ^C "foo" barbar' >tiny.nanorc
valgrind --leak-check=full src/nano --rc=tiny.nanorc 2>TRAIL; cat TRAIL

Then type ^X.  Result:
==8781== 4 bytes in 1 blocks are definitely lost in loss record 12 of 419
==8781==    at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8781==    by 0x136B4B: nmalloc (utils.c:288)
==8781==    by 0x136C3A: measured_copy (utils.c:323)
==8781==    by 0x136C93: copy_of (utils.c:334)
==8781==    by 0x129933: parse_binding (rcfile.c:796)
==8781==    by 0x12B327: parse_rcfile (rcfile.c:1505)
==8781==    by 0x12BD4F: parse_one_nanorc (rcfile.c:1688)
==8781==    by 0x12BE76: do_rcfiles (rcfile.c:1716)
==8781==    by 0x124A2E: main (nano.c:2160)

The problem is that the allocated expansion string is not freed when the string bind is abandonned because of a faulty menu specification.

Benno Schulenberg <bens>
Group administrator

 

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

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)
  •  

    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.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-11-16 bens Open/ClosedOpen Closed
    2022-08-31 bens StatusIn Progress Fixed
    2022-08-31 bens StatusNone In Progress

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code