Author: chromatic
Date: Thu Dec 4 23:49:46 2008
New Revision: 33500
Modified:
trunk/src/gc/resources.c
Log:
[GC] Added a pointer check before dereferencing, as reported by Coverity Scan
in CID #8 (though strangely, it's a different problem than the original).
Modified: trunk/src/gc/resources.c
==============================================================================
--- trunk/src/gc/resources.c (original)
+++ trunk/src/gc/resources.c Thu Dec 4 23:49:46 2008
@@ -338,7 +338,6 @@
char *cur_spot; /* Where we're currently copying to */
Small_Object_Arena *cur_buffer_arena;
- INTVAL *ref_count = NULL;
Arenas * const arena_base = interp->arena_base;
/* Bail if we're blocked */
@@ -421,6 +420,8 @@
UINTVAL i;
for (i = cur_buffer_arena->used; i; --i) {
+ INTVAL *ref_count = NULL;
+
/* ! (on_free_list | constant | external | sysmem) */
if (PObj_buflen(b) && PObj_is_movable_TESTALL(b)) {
ptrdiff_t offset = 0;
@@ -488,13 +489,17 @@
/* Finally, let the tail know that we've moved, so
* that any other references can know to look for
* us and not re-copy */
- *ref_count |= Buffer_moved_FLAG;
+ if (ref_count)
+ *ref_count |= Buffer_moved_FLAG;
}
+
PObj_bufstart(b) = cur_spot;
+
if (PObj_is_string_TEST(b)) {
((STRING *)b)->strstart = (char *)PObj_bufstart(b)
+
offset;
}
+
cur_spot += PObj_buflen(b);
}
}