From: Russ Cox Date: Tue, 12 Mar 2013 21:57:13 +0000 (-0400) Subject: cmd/ld: fix 'use after free' error in new obj code X-Git-Tag: go1.1rc2~541 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f7ad816c5c13d334f1c0d350041e95cb507e47bc;p=gostls13.git cmd/ld: fix 'use after free' error in new obj code Many thanks to Elias Naur for finding this with Valgrind on Linux. Perhaps this is what is breaking the windows/amd64 builder. R=golang-dev, r CC=golang-dev https://golang.org/cl/7595044 --- diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c index cbd947dc82..450a83716e 100644 --- a/src/cmd/ld/lib.c +++ b/src/cmd/ld/lib.c @@ -528,7 +528,7 @@ ldhostobj(void (*ld)(Biobuf*, char*, int64, char*), Biobuf *f, char *pkg, int64 } h = &hostobj[nhostobj++]; h->ld = ld; - h->pkg = pkg; + h->pkg = estrdup(pkg); h->pn = estrdup(pn); h->file = estrdup(file); h->off = Boffset(f);