1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 07:16:23 -05:00

Fix newly reported coverity issues (Memory leak and flase positive of Use after Free).

This commit is contained in:
Renaud 2017-05-27 16:07:56 +08:00
parent 5368877ebb
commit 5d46ffc3dc
2 changed files with 7 additions and 3 deletions

8
exec.c
View File

@ -712,6 +712,7 @@ static int dobuf(struct buffer *bp)
c = mdbugout( "<<<%s:%d:%s>>>", bp->b_bname, execlevel, eline) ; c = mdbugout( "<<<%s:%d:%s>>>", bp->b_bname, execlevel, eline) ;
if( c == abortc) { if( c == abortc) {
freewhile( whlist) ; freewhile( whlist) ;
free( einit) ;
return FALSE ; return FALSE ;
} else if( c == metac) { } else if( c == metac) {
macbug = FALSE ; macbug = FALSE ;
@ -733,6 +734,7 @@ static int dobuf(struct buffer *bp)
if (dirnum == NUMDIRS) { if (dirnum == NUMDIRS) {
mlwrite("%%Unknown Directive"); mlwrite("%%Unknown Directive");
freewhile(whlist); freewhile(whlist);
free( einit) ;
return FALSE; return FALSE;
} }
@ -752,9 +754,9 @@ static int dobuf(struct buffer *bp)
/* allocate the space for the line */ /* allocate the space for the line */
linlen = strlen(eline); linlen = strlen(eline);
if ((mp = lalloc(linlen)) == NULL) { if ((mp = lalloc(linlen)) == NULL) {
mlwrite free( einit) ;
("Out of memory while storing macro"); mlwrite( "Out of memory while storing macro") ;
return FALSE; return FALSE ;
} }
/* copy the text into the new line */ /* copy the text into the new line */

View File

@ -9,6 +9,7 @@
* *
*/ */
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include "basic.h" #include "basic.h"
@ -623,6 +624,7 @@ int newsize(int f, int n)
} else { } else {
/* rebuild the window structure */ /* rebuild the window structure */
assert( wheadp->w_toprow == 0) ; /* proves coverity wrong */
nextwp = wheadp; nextwp = wheadp;
wp = NULL; wp = NULL;
lastwp = NULL; lastwp = NULL;