]> granicus.if.org Git - gc/commitdiff
Workaround 'resource leak' false positives in alloc_MS, bl/envfile_init
authorIvan Maidanski <ivmai@mail.ru>
Tue, 20 Dec 2016 07:41:40 +0000 (10:41 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 20 Dec 2016 07:41:40 +0000 (10:41 +0300)
* blacklst.c (GC_bl_init): Add assertion that GC_old_stack_bl and
GC_incomplete_stack_bl are both null prior to their assignment (to the
result of GC_scratch_alloc).
* mark.c (alloc_mark_stack): Replace GC_mark_stack_size!=0 with
GC_mark_stack!=NULL (to ensure no memory leak when GC_mark_stack is
assigned for the first time).
* misc.c [GC_READ_ENV_FILE && (MSWIN32 || MSWINCE || CYGWIN32)]
(GC_envfile_init): Add assertion that GC_envfile_content is null prior
to its assignment.

blacklst.c
mark.c
misc.c

index 449130df18963e78ffb5da1b27b2c31764f7298e..c06fbddec367af7b30605265b7278e2cfceac060 100644 (file)
@@ -109,6 +109,7 @@ GC_INNER void GC_bl_init(void)
     if (!GC_all_interior_pointers) {
       GC_bl_init_no_interiors();
     }
+    GC_ASSERT(NULL == GC_old_stack_bl && NULL == GC_incomplete_stack_bl);
     GC_old_stack_bl = (word *)GC_scratch_alloc(sizeof(page_hash_table));
     GC_incomplete_stack_bl = (word *)GC_scratch_alloc(sizeof(page_hash_table));
     if (GC_old_stack_bl == 0 || GC_incomplete_stack_bl == 0) {
diff --git a/mark.c b/mark.c
index e93b433e85d4d5562228850fcf488c7a1f86ae63..f5b9dc49664c744165dedd9c06e669c040d23646 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -1277,7 +1277,7 @@ static void alloc_mark_stack(size_t n)
 #   endif
 
     GC_mark_stack_too_small = FALSE;
-    if (GC_mark_stack_size != 0) {
+    if (GC_mark_stack != NULL) {
         if (new_stack != 0) {
           if (recycle_old) {
             /* Recycle old space */
diff --git a/misc.c b/misc.c
index 2b6494db798bc49cbfaabd11e9b07fa09973606c..16a833ad41c4ed8fcd0b508cb11445e93af5b5a0 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -707,6 +707,7 @@ GC_API void GC_CALL GC_get_heap_usage_safe(GC_word *pheap_size,
        if (content[ofs] == '\r' || content[ofs] == '\n')
          content[ofs] = '\0';
       }
+      GC_ASSERT(NULL == GC_envfile_content);
       GC_envfile_length = len + 1;
       GC_envfile_content = content;
 #   endif