Commit 916eea04 authored by Shenghou Ma's avatar Shenghou Ma Committed by Russ Cox

5l, 6l, 8l, ld: remove memory leaks

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5569085
parent ba31d662
...@@ -91,6 +91,7 @@ needlib(char *name) ...@@ -91,6 +91,7 @@ needlib(char *name)
/* reuse hash code in symbol table */ /* reuse hash code in symbol table */
p = smprint(".dynlib.%s", name); p = smprint(".dynlib.%s", name);
s = lookup(p, 0); s = lookup(p, 0);
free(p);
if(s->type == 0) { if(s->type == 0) {
s->type = 100; // avoid SDATA, etc. s->type = 100; // avoid SDATA, etc.
return 1; return 1;
......
...@@ -112,6 +112,7 @@ needlib(char *name) ...@@ -112,6 +112,7 @@ needlib(char *name)
/* reuse hash code in symbol table */ /* reuse hash code in symbol table */
p = smprint(".elfload.%s", name); p = smprint(".elfload.%s", name);
s = lookup(p, 0); s = lookup(p, 0);
free(p);
if(s->type == 0) { if(s->type == 0) {
s->type = 100; // avoid SDATA, etc. s->type = 100; // avoid SDATA, etc.
return 1; return 1;
......
...@@ -108,6 +108,7 @@ needlib(char *name) ...@@ -108,6 +108,7 @@ needlib(char *name)
/* reuse hash code in symbol table */ /* reuse hash code in symbol table */
p = smprint(".dynlib.%s", name); p = smprint(".dynlib.%s", name);
s = lookup(p, 0); s = lookup(p, 0);
free(p);
if(s->type == 0) { if(s->type == 0) {
s->type = 100; // avoid SDATA, etc. s->type = 100; // avoid SDATA, etc.
return 1; return 1;
......
...@@ -482,6 +482,7 @@ loaddynimport(char *file, char *pkg, char *p, int n) ...@@ -482,6 +482,7 @@ loaddynimport(char *file, char *pkg, char *p, int n)
if(q) if(q)
*q++ = '\0'; *q++ = '\0';
s = lookup(name, 0); s = lookup(name, 0);
free(name);
if(s->type == 0 || s->type == SXREF) { if(s->type == 0 || s->type == SXREF) {
s->dynimplib = lib; s->dynimplib = lib;
s->dynimpname = def; s->dynimpname = def;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment