[m-dev.] diff: fix bug with GC_FREE(NULL) and -DGC_DEBUG

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Oct 15 03:16:36 AEST 1999


Estimated hours taken: 0.25

boehm_gc/dbg_mlc.c:
	Fix a bug that caused a segmentation fault for
	`GC_FREE(NULL)' when GC_DEBUG was defined.

Workspace: /d-drive/home/hg/fjh/mercury
Index: boehm_gc/dbg_mlc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/boehm_gc/dbg_mlc.c,v
retrieving revision 1.10
diff -u -r1.10 dbg_mlc.c
--- boehm_gc/dbg_mlc.c	1999/10/07 11:23:08	1.10
+++ boehm_gc/dbg_mlc.c	1999/10/14 17:09:54
@@ -533,11 +533,13 @@
 {
     register GC_PTR base = GC_base(p);
     register ptr_t clobbered;
-    
+
+    if (p == 0) return;
+    base = GC_base(p);
     if (base == 0) {
         GC_err_printf1("Attempt to free invalid pointer %lx\n",
         	       (unsigned long)p);
-        if (p != 0) ABORT("free(invalid pointer)");
+        ABORT("free(invalid pointer)");
     }
     if ((ptr_t)p - (ptr_t)base != sizeof(oh)) {
         GC_err_printf1(

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list