1
0
mirror of https://github.com/golang/go synced 2024-11-21 23:34:42 -07:00

5g: fix memory corruption

R=ken2
CC=golang-dev
https://golang.org/cl/5666043
This commit is contained in:
Russ Cox 2012-02-14 01:13:14 -05:00
parent adb1a6ce3c
commit 1c987a321f

View 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");