[En-Nut-Discussion] Should free test DEADBEEF by default?

Ole Reinhardt ole.reinhardt at embedded-it.de
Tue Apr 22 13:21:21 CEST 2008


Hi,

> sorry for the spam yesterday. :-/
> 
> Is there a good reason to/not check the DEADBEEF when freeing mem. After 
> all it's likely that (1) the boundaries were not obeyed or (2) a wrong 
> pointer got freed. Shouldn't free just return -1 in this case?

Normal libc implementation of free defines free as a void function.

http://linux.die.net/man/3/malloc

On the other hand: If you did not obeye the boundaries of your allocated
memory everthing else will likely fail long before the memory get freed
again.

Without a mmu you does not have much possibilities to detect buffer
overflows.

Regards,

Ole Reinhardt

-- 
 _____________________________________________________________
|                                                             |
| Embedded-IT          Hard- und Softwarelösungen             |
|                                                             |
| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
| 57076 Siegen         eMail:    ole.reinhardt at embedded-it.de |
| Germany              Web:         http://www.embedded-it.de |
|                      UstID / VAT:       DE198944716         |
|_____________________________________________________________|




More information about the En-Nut-Discussion mailing list