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

View File

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