This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Segmentation Fault: new char[12]


>         I don't think the "memory leak" is your biggest problem. The
> visible result of a memory leak is that malloc() returns 0 after some
> amount of time, but your code checks for that. Getting a _SEGFAULT_
> from malloc() (or free(), or whatever) is almost always caused by
> your application corrupting the malloc "headers" that are often
> stored adjacent to the allocated memory. You need to be looking for
> array-bounds violations, not memory-leaks.

Freeing something twice can also do bad things to the free list and
cause a later malloc or free to SEGFAULT.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]