From 1c987a321f5013517a0c1987826f9595dde7cb72 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Feb 2012 01:13:14 -0500 Subject: [PATCH] 5g: fix memory corruption R=ken2 CC=golang-dev https://golang.org/cl/5666043 --- src/cmd/5g/gsubr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/5g/gsubr.c b/src/cmd/5g/gsubr.c index 94caeb09188..c938f8b00bd 100644 --- a/src/cmd/5g/gsubr.c +++ b/src/cmd/5g/gsubr.c @@ -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");