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.

_______________________________________________
bug-ed mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-ed

Reply via email to