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

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



Your message dated Sun, 11 Feb 2007 23:09:28 +0100
with message-id <20070211220928.GA14329@hades.madism.org>
and subject line obstack_free() can't be called multiple times
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
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



--- End Message ---
--- Begin Message ---
On Tue, Sep 03, 2002 at 12:24:32PM -0500, Adam Heath wrote:
> 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.

  SOrry for the long time, but this is the intended behaviour, see the
obstack documentation (e.g. on[0]), quoting:

--- void obstack_free (struct obstack *obstack-ptr, void *object)
    [...]
    Note that if object is a null pointer, the result is an
    uninitialized obstack. To free all memory in an obstack but leave it
    valid for further allocation, call obstack_free with the address of
    the first object allocated on the obstack
    [...]

  Hence we won't change it as a "workaround" for what you want to do
exists. Cheers,

  [0] http://www.gnu.org/software/libc/manual/html_node/Freeing-Obstack-Objects.html#Freeing-Obstack-Objects
-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

Attachment: pgpY3owr2G8KT.pgp
Description: PGP signature


--- End Message ---

Reply to: