bug-ed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-ed] Memory and ressource leak in ed


From: Antonio Diaz Diaz
Subject: Re: [Bug-ed] Memory and ressource leak in ed
Date: Mon, 20 Jul 2015 15:51:44 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.8.1.4) Gecko/20070601 SeaMonkey/1.1.2

Hello Cédric,

Cédric Picard wrote:
I did a static analysis of ed 1.12 with cppcheck and found 3 issues:

Thank you very much for reporting this.

I have fixed io.c as you propose, but for the memory leak in buffer.c I have postponed the allocation of lp instead:

--- ed-1.12/buffer.c      2015-06-07 19:10:25.000000000 +0200
+++ ed-1.13-pre1/buffer.c 2015-07-20 11:21:33.000000000 +0200
@@ -439,11 +439,10 @@
 const char * put_sbuf_line( const char * const buf, const int size,
                             const int addr )
   {
-  line_t * const lp = dup_line_node( 0 );
   const char * const p = (const char *) memchr( buf, '\n', size );
+  line_t * lp;
   int len;

-  if( !lp ) return 0;
   if( !p ) { set_error_msg( "Line too long" ); return 0; }
   len = p - buf;
   /* out of position */
@@ -465,6 +464,8 @@
     set_error_msg( "Cannot write temp file" );
     return 0;
     }
+  lp = dup_line_node( 0 );
+  if( !lp ) return 0;
   lp->pos = sfpos; lp->len = len;
   add_line_node( lp, addr );
   ++current_addr_;


You can find a corrected version of ed at http://download-mirror.savannah.gnu.org/releases/ed/ed-1.13-pre1.tar.lz


Best regards,
Antonio.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]