Index: trunk/archive/pslib/src/Utils/memory.c
===================================================================
--- trunk/archive/pslib/src/Utils/memory.c	(revision 203)
+++ trunk/archive/pslib/src/Utils/memory.c	(revision 227)
@@ -4,4 +4,8 @@
 #include "psUtils.h"
 #include "Private/p_psMemory.h"
+
+#undef malloc				// _We_ are allowed to call these
+#undef realloc
+#undef free
 
 #undef psAlloc				// don't get the __FILE__ versions
@@ -292,12 +296,15 @@
     }
 
-    if (bad_memblock(ptr, 0) || ptr->refCounter != 1) {
-	memProblemCB(ptr, file, lineno);
-    }
-
-    ptr->refCounter--;
-    memBlocks[ptr->id] = NULL;		// XXX sub-optimal! Can't check
-    					// freed blocks for corruption
-    free(ptr);
+    if (bad_memblock(ptr, 0)) {
+	memProblemCB(ptr, file, lineno); // we may not own this block; don't free it
+    } else {
+	if (ptr->refCounter != 1) {
+	    memProblemCB(ptr, file, lineno);
+	}
+	ptr->refCounter--;
+	memBlocks[ptr->id] = NULL;	// XXX sub-optimal! Can't check
+					// freed blocks for corruption
+	free(ptr);
+    }
 }
 
