Re: BUG REPORT tin 1.8.3 release 20070201 ("Scotasay") [UNIX]
Urs Janßen <[email protected]> Sun, 25 Nov 2007 18:31:23 +0100
| Newsgroups | gmane.network.tin.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Nov 25, 2007 at 03:26:53AM -0600, Philip M. White wrote:
> When I view a newsgroup where I have never posted before and press 'W',
actually this happens when the posted-histiry file is empty
> tin prints the following message:
> tin: memory exhausted trying to allocate 0 bytes in file ./page.c line 2260
> ... and crashes.
a possible fix: allow realloc(x, null)
--- memory.c 2006-12-22 02:41:55.000000000 +0100
+++ memory.c 2007-11-25 18:30:48.717170884 +0100
@@ -530,11 +530,15 @@
debug_print_malloc(FALSE, file, line, size);
#endif /* DEBUG */
- p = ((!p) ? (calloc(1, size)) : realloc(p, size));
-
- if (p == NULL) {
- error_message(txt_out_of_memory, tin_progname, size, file, line);
- giveup();
+ if (p && !size) {
+ free(p);
+ return NULL;
+ } else {
+ p = ((!p) ? (calloc(1, size)) : realloc(p, size));
+ if (p == NULL && size != 0) {
+ error_message(txt_out_of_memory, tin_progname, size, file, line);
+ giveup();
+ }
+ return p;
}
- return p;
}