bugGNU nano - Bugs: bug #47153, memory leak w/file reading

 
 

bug #47153: memory leak w/file reading

Submitted by:  Mike Frysinger <vapier>
Submitted on:  Mon 15 Feb 2016 05:45:57 AM UTC  
 
Severity: 3 - NormalStatus: Fixed
Assigned to: Benno Schulenberg <bens>Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Mon 15 Feb 2016 01:00:05 PM UTC, comment #1:

Fixed in SVN, r5646.

I have two files Readme.txt on my system, both are DOS files. One leaked, the other not. Turns out that nano leaks whenever the last line of the file doesn't end in a newline.

The error was that it freed only the struct, not the line data contained within it. And it freed it only when it wasn't the first line, so if the file consisted of just one unterminated line, nano would leak also the struct.

Thanks for reporting.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 15 Feb 2016 05:45:57 AM UTC, original submission:

using svn rev 5637:

$ nano -I Readme.txt
<ctrl+x to exit>

==3494==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 19 byte(s) in 1 object(s) allocated from:
#0 0x7f6add29000a in malloc (/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/libasan.so.2+0x9d00a)
#1 0x455dde in nmalloc .../utils.c:388
#2 0x455ea4 in mallocstrncpy .../utils.c:418
#3 0x455f06 in mallocstrcpy .../utils.c:428
#4 0x412549 in read_line .../files.c:683
#5 0x412f4f in read_file .../files.c:862
#6 0x411740 in open_buffer .../files.c:481
#7 0x43411d in main .../nano.c:2631
#8 0x7f6adc5b25ef in __libc_start_main (/lib64/libc.so.6+0x205ef)

SUMMARY: AddressSanitizer: 19 byte(s) leaked in 1 allocation(s).

Mike Frysinger <vapier>
Project Member

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bens (Posted a comment)
  • -unavailable- added by vapier (Submitted the item)
  •  

    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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 27 Feb 2016 03:08:57 PM UTCbensOpen/ClosedOpen=>Closed
    Mon 15 Feb 2016 01:00:05 PM UTCbensStatusNone=>Fixed
      Assigned toNone=>bens

    Back to the top


    Powered by Savane 3.1-cleanup1