[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] linebuffer.c bug
From: |
Paul Eggert |
Subject: |
Re: [Bug-gnulib] linebuffer.c bug |
Date: |
24 Sep 2003 14:01:59 -0700 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
Simon Josefsson <address@hidden> writes:
> it may be good to document that readlinebuffer() never return
> anything other than NULL or the input linebuffer parameter,
That's already in the comment just before readlinebuffer, isn't it?
> Should the 'struct linebuffer *' be allocated by the application or by
> linebuffer.c? Right now the code free the pointer, but it never
> allocate it, which seems like a bad idea.
Yes, it's bogus. I don't know of any program that uses freebuffer;
coreutils simply invokes 'free' itself. The least intrusive change is
to change freebuffer to not free its argument; that will at worst
cause a memory leak in the (nonexistent?) programs that use it. So I
installed this. (Hmm, maybe freebuffer's argument should be const *
now? But I didn't do that.)
2003-09-24 Paul Eggert <address@hidden>
* linebuffer.c (freebuffer): Don't free the argument, just
the buffer associated with the argument. Bug reported by
Simon Josefsson.
Index: linebuffer.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/linebuffer.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -p -u -r1.15 -r1.16
--- linebuffer.c 16 Sep 2003 20:00:38 -0000 1.15
+++ linebuffer.c 24 Sep 2003 20:56:42 -0000 1.16
@@ -87,11 +87,10 @@ readlinebuffer (struct linebuffer *lineb
return linebuffer;
}
-/* Free linebuffer LINEBUFFER and its data, all allocated with malloc. */
+/* Free the buffer that was allocated for linebuffer LINEBUFFER. */
void
freebuffer (struct linebuffer *linebuffer)
{
free (linebuffer->buffer);
- free (linebuffer);
}