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
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;

Reply via email to