And you always need a Borland compiler around dude!
Announcement
Collapse
No announcement yet.
C help needed
Collapse
X
-
Ehrm, writing outside the allocated memory usually means that you are writing in memory management data, so no wonder why you chrashWith or without religion, you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion.
Steven Weinberg
Comment
-
Originally posted by Kuciwalker
It should just segfault though...With or without religion, you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion.
Steven Weinberg
Comment
-
Originally posted by Kuciwalker
It should just segfault though...
The malloc implementation is free to use some of its allocated memory for control structures, for example a linked list of allocated memory. For example the elements of this list could be interspersed with the actual malloced memory.
So if you allocate 16 bytes, but write 20 to the pointer you get, you will, say, overwrite the linked list head of the following element in malloc's linked list. So when you call free() it will find an invalid data structure.
For debugging, and depending on the compiler, you can instruct the compiler to link against an alternative malloc implementation which is implemented to discover any corruption sooner.http://www.hardware-wiki.com - A wiki about computers, with focus on Linux support.
Comment
-
Comment