]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/ld: fix off-by-one error when emitting symbol names
authorShenghou Ma <minux@golang.org>
Sat, 11 Oct 2014 00:30:24 +0000 (20:30 -0400)
committerShenghou Ma <minux@golang.org>
Sat, 11 Oct 2014 00:30:24 +0000 (20:30 -0400)
I diffed the output of `nm -n gofmt' before and after this change,
and verified that all changes are correct and all corrupted symbol
names are fixed.

Fixes #8906.

LGTM=iant, cookieo9
R=golang-codereviews, iant, cookieo9
CC=golang-codereviews
https://golang.org/cl/159750043

src/cmd/ld/macho.c

index 61306bb7ca71989cf1993f946935bc22c0a63b5e..fe7e10e466691249f8dee517a7a3ad3c7c5114c2 100644 (file)
@@ -590,8 +590,7 @@ machosymtab(void)
                if(strstr(s->extname, "ยท") == nil) {
                        addstring(symstr, s->extname);
                } else {
-                       p = s->extname;
-                       while (*p++ != '\0') {
+                       for(p = s->extname; *p; p++) {
                                if((uchar)*p == 0xc2 && (uchar)*(p+1) == 0xb7) {
                                        adduint8(ctxt, symstr, '.');
                                        p++;