mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-27 11:52:03 +00:00
libmach: plug memory leak
Change-Id: I08cb7227c071c7fc2e30f43e07bcf599fc1d174a
This commit is contained in:
parent
a4e59b3702
commit
2c97de1a26
1 changed files with 4 additions and 1 deletions
|
@ -191,7 +191,7 @@ elfinit(int fd)
|
||||||
ElfHdrBytes h32;
|
ElfHdrBytes h32;
|
||||||
ElfHdrBytes64 h64;
|
ElfHdrBytes64 h64;
|
||||||
} hdrb;
|
} hdrb;
|
||||||
void *p;
|
void *p = nil;
|
||||||
ElfSect *s;
|
ElfSect *s;
|
||||||
|
|
||||||
e = mallocz(sizeof(Elf), 1);
|
e = mallocz(sizeof(Elf), 1);
|
||||||
|
@ -234,6 +234,7 @@ elfinit(int fd)
|
||||||
unpackprog(h, &e->prog[i], p);
|
unpackprog(h, &e->prog[i], p);
|
||||||
}
|
}
|
||||||
free(p);
|
free(p);
|
||||||
|
p = nil;
|
||||||
|
|
||||||
e->nsect = h->shnum;
|
e->nsect = h->shnum;
|
||||||
if(e->nsect == 0)
|
if(e->nsect == 0)
|
||||||
|
@ -247,6 +248,7 @@ elfinit(int fd)
|
||||||
unpacksect(h, &e->sect[i], p);
|
unpacksect(h, &e->sect[i], p);
|
||||||
}
|
}
|
||||||
free(p);
|
free(p);
|
||||||
|
p = nil;
|
||||||
|
|
||||||
if(h->shstrndx >= e->nsect){
|
if(h->shstrndx >= e->nsect){
|
||||||
fprint(2, "warning: bad string section index %d >= %d", h->shstrndx, e->nsect);
|
fprint(2, "warning: bad string section index %d >= %d", h->shstrndx, e->nsect);
|
||||||
|
@ -287,6 +289,7 @@ nosects:
|
||||||
return e;
|
return e;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
free(p);
|
||||||
free(e->sect);
|
free(e->sect);
|
||||||
free(e->prog);
|
free(e->prog);
|
||||||
free(e->shstrtab);
|
free(e->shstrtab);
|
||||||
|
|
Loading…
Reference in a new issue