sam: fix memory leak
This commit is contained in:
parent
982ee70f45
commit
c8c58f8cfd
2 changed files with 4 additions and 3 deletions
|
@ -138,7 +138,7 @@ termwrite(char *s)
|
|||
else
|
||||
Strinsert(&cmdstr, p, cmdstr.n);
|
||||
cmdptadv += p->n;
|
||||
free(p);
|
||||
freetmpstr(p);
|
||||
}else
|
||||
Write(2, s, strlen(s));
|
||||
}
|
||||
|
|
|
@ -136,10 +136,10 @@ emalloc(ulong n)
|
|||
{
|
||||
void *p;
|
||||
|
||||
p = malloc(n);
|
||||
p = mallocz(n, 1);
|
||||
if(p == 0)
|
||||
panic("malloc fails");
|
||||
memset(p, 0, n);
|
||||
setmalloctag(p, getcallerpc(&n));
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -149,5 +149,6 @@ erealloc(void *p, ulong n)
|
|||
p = realloc(p, n);
|
||||
if(p == 0)
|
||||
panic("realloc fails");
|
||||
setmalloctag(p, getcallerpc(&p));
|
||||
return p;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue