Thread View: gnu.utils.bug
1 messages
1 total messages
Started by Peter R. Ham
Tue, 06 Jun 1989 16:58
unportable use of malloc in ld.c
Author: Peter R. Ham
Date: Tue, 06 Jun 1989 16:58
Date: Tue, 06 Jun 1989 16:58
64 lines
1935 bytes
1935 bytes
I don't have a version number for this code, but the last date in the
ChangeLog is:
Thu Dec 29 01:48:03 1988 Richard Stallman (rms at sugar-bombs.ai.mit.edu)
The following code implicity assumes that xmalloc() returns zeroed memory:
main()
...
cmdline_references =
(struct glosym **) xmalloc (cl_refs_allocated
* sizeof(struct glosym *));
It's my understanding that "malloc()", which "xmalloc()" calls is not
guarranteed return a pointer to zero filled memory.
This dependecny can be fixed by clearing the memory with bzero inside xmalloc()
or appending:
bzero((char *) cmdline_references, cl_refs_allocated *
sizeof(struct glosym *));
After the call to xmalloc.
Later on, this assumption is used:
void
add_cmdline_ref (sp)
struct glosym *sp;
{
struct glosym **ptr;
for (ptr = cmdline_references;
ptr < cmdline_references + cl_refs_allocated && *ptr;(RIGHT HERE!!!)
ptr++)
;
if (ptr == cmdline_references + cl_refs_allocated)
{
int diff = ptr - cmdline_references;
cl_refs_allocated *= 2;
cmdline_references = (struct glosym **)
xrealloc (cmdline_references,
cl_refs_allocated * sizeof (struct glosym *));
ptr = cmdline_references + diff;
}
*ptr++ = sp;
*ptr = (struct glosym *) 0;
}
and there is similar code in "do_warnings()".
--
Peter Ham PO Box 3430 (415) 324-4782
MS Computer Science Student Stanford, CA ham@polya.stanford.edu
Stanford University 94309
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads