public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libgo patch committed: Don't crash if freeing small map
@ 2015-03-09 23:43 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2015-03-09 23:43 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 179 bytes --]

This libgo patch fixes a crash when explicitly freeing a small map.
This is PR 65349.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

[-- Attachment #2: foo.txt --]
[-- Type: text/plain, Size: 551 bytes --]

diff -r cf89d7a7f372 libgo/runtime/go-map-index.c
--- a/libgo/runtime/go-map-index.c	Mon Mar 09 16:36:59 2015 -0700
+++ b/libgo/runtime/go-map-index.c	Mon Mar 09 16:41:25 2015 -0700
@@ -8,6 +8,7 @@
 #include <stdlib.h>
 
 #include "runtime.h"
+#include "malloc.h"
 #include "go-alloc.h"
 #include "go-assert.h"
 #include "map.h"
@@ -63,7 +64,8 @@
 	}
     }
 
-  __go_free (old_buckets);
+  if (old_bucket_count * sizeof (void *) >= TinySize)
+    __go_free (old_buckets);
 
   map->__bucket_count = new_bucket_count;
   map->__buckets = new_buckets;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-03-09 23:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-09 23:43 libgo patch committed: Don't crash if freeing small map Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).