]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/6c, cmd/8c: fix stack allocated Biobuf leaking at exit
authorDave Cheney <dave@cheney.net>
Wed, 20 Mar 2013 12:42:00 +0000 (23:42 +1100)
committerDave Cheney <dave@cheney.net>
Wed, 20 Mar 2013 12:42:00 +0000 (23:42 +1100)
Fixes #5085.

{6,8}c/swt.c allocates a third Biobuf in automatic memory which is not terminated at the end of the function. This causes the buffer to be 'in use' when the batexit handler fires, confusing valgrind.

Huge thanks to DMorsing for the diagnosis.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/7844044

src/cmd/6c/swt.c
src/cmd/8c/swt.c

index 58d6d51291caae0b15f0bfe0ed347966957a93da..541c7beaaac47e3d17a52047c65a723bba1b5b60 100644 (file)
@@ -320,7 +320,7 @@ outcode(void)
                zaddr(&b, &p->from, sf);
                zaddr(&b, &p->to, st);
        }
-       Bflush(&b);
+       Bterm(&b);
        close(f);
        firstp = P;
        lastp = P;
index d331eee1ae14e426bfcd274090ec5f758fd19881..1b8ceb0c69d001e720611254ce7686416c235a99 100644 (file)
@@ -324,7 +324,7 @@ outcode(void)
                zaddr(&b, &p->from, sf);
                zaddr(&b, &p->to, st);
        }
-       Bflush(&b);
+       Bterm(&b);
        close(f);
        firstp = P;
        lastp = P;