My program is crashing, apparently somewhere down inside malloc, but I can't see anything wrong with it.
It is unfortunately very easy to corrupt malloc's internal data structures, and the resulting problems can be stubborn. The most common source of problems is writing more to a malloc'ed region than it was allocated to hold; a particularly common bug is to malloc(strlen(s)) instead of strlen(s) + 1. Other problems may involve using pointers to freed storage, freeing pointers twice, freeing pointers not obtained from malloc, or trying to realloc a null pointer (see question 7.30).
See also questions 7.26, 16.8, and 18.2.
Read sequentially: prev next up top
This page by Steve Summit // Copyright 1995 // mail feedback