]> Cypherpunks repositories - gostls13.git/commitdiff
5g: fix memory corruption
authorRuss Cox <rsc@golang.org>
Tue, 14 Feb 2012 06:13:14 +0000 (01:13 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 14 Feb 2012 06:13:14 +0000 (01:13 -0500)
R=ken2
CC=golang-dev
https://golang.org/cl/5666043

src/cmd/5g/gsubr.c

index 94caeb0918879761da36fbd62a4bed832d136ce5..c938f8b00bd20834109aae5397d1c72a5a75abd2 100644 (file)
@@ -346,7 +346,7 @@ anyregalloc(void)
        return 0;
 }
 
-uintptr regpc[REGALLOC_RMAX+1];
+uintptr regpc[REGALLOC_FMAX+1];
 
 /*
  * allocate register of type t, leave in n.
@@ -451,7 +451,7 @@ regfree(Node *n)
        if(n->op != OREGISTER && n->op != OINDREG)
                fatal("regfree: not a register");
        i = n->val.u.reg;
-       if(i < 0 || i >= sizeof(reg))
+       if(i < 0 || i >= nelem(reg) || i >= nelem(regpc))
                fatal("regfree: reg out of range");
        if(reg[i] <= 0)
                fatal("regfree: reg not allocated");