[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#159493: obstack_free() can't be called multiple times



package: libc6
tag: patch

obstack_free and _obstack_free do not properly reset the obstack to an empty
state, in the case when freeing all objects(NULL).  This is because ->chunk is
not set when lp == NULL.

The following patch fixes it for me.

Index: optlib/obstack.c
===================================================================
RCS file: /cvs/dpkg/dpkg/optlib/obstack.c,v
retrieving revision 1.1
diff -u -r1.1 obstack.c
--- optlib/obstack.c	14 Jan 2001 20:30:46 -0000	1.1
+++ optlib/obstack.c	3 Sep 2002 17:21:36 -0000
@@ -397,14 +397,14 @@
       h->maybe_empty_object = 1;
     }
   if (lp)
-    {
-      h->object_base = h->next_free = (char *) (obj);
-      h->chunk_limit = lp->limit;
-      h->chunk = lp;
-    }
+    h->chunk_limit = lp->limit;
   else if (obj != 0)
     /* obj is not in any of the chunks! */
     abort ();
+  else
+    h->chunk_limit = 0;
+  h->object_base = h->next_free = (char *) (obj);
+  h->chunk = lp;
 }

 /* This function is used from ANSI code.  */
@@ -431,14 +431,14 @@
       h->maybe_empty_object = 1;
     }
   if (lp)
-    {
-      h->object_base = h->next_free = (char *) (obj);
-      h->chunk_limit = lp->limit;
-      h->chunk = lp;
-    }
+    h->chunk_limit = lp->limit;
   else if (obj != 0)
     /* obj is not in any of the chunks! */
     abort ();
+  else
+    h->chunk_limit = 0;
+  h->object_base = h->next_free = (char *) (obj);
+  h->chunk = lp;
 }

 int




Reply to: