From: Keith Randall Date: Wed, 8 Jan 2014 20:41:26 +0000 (-0800) Subject: runtime: deallocate specials before deallocating the underlying object. X-Git-Tag: go1.3beta1~1030 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e7d010a6a7c19c3af6a8157356d09cea23eab198;p=gostls13.git runtime: deallocate specials before deallocating the underlying object. R=dvyukov CC=golang-codereviews https://golang.org/cl/48840043 --- diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index 81cda75dfd..9a25029586 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -180,16 +180,18 @@ runtime·free(void *v) runtime·printf("free %p: not an allocated block\n", v); runtime·throw("free runtime·mlookup"); } + size = s->elemsize; + sizeclass = s->sizeclass; if(raceenabled) runtime·racefree(v); - // Find size class for v. - sizeclass = s->sizeclass; + if(s->specials != nil) + runtime·freeallspecials(s, v, size); + c = m->mcache; if(sizeclass == 0) { // Large object. - size = s->npages<start<local_largefree += size; } else { // Small object. - size = runtime·class_to_size[sizeclass]; if(size > sizeof(uintptr)) ((uintptr*)v)[1] = (uintptr)0xfeedfeedfeedfeedll; // mark as "needs to be zeroed" // Must mark v freed before calling MCache_Free: @@ -213,8 +214,6 @@ runtime·free(void *v) c->local_nsmallfree[sizeclass]++; runtime·MCache_Free(c, v, sizeclass, size); } - if(s->specials != nil) - runtime·freeallspecials(s, v, size); m->mallocing = 0; }