]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/ld: fix 'use after free' error in new obj code
authorRuss Cox <rsc@golang.org>
Tue, 12 Mar 2013 21:57:13 +0000 (17:57 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 12 Mar 2013 21:57:13 +0000 (17:57 -0400)
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

src/cmd/ld/lib.c

index cbd947dc82f46597fd4183d9f14a7d0e251e0d0d..450a83716e0770873de3a5beafb45c906ac64a88 100644 (file)
@@ -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);