Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dereferencing a null pointer

Why I can't dereference a null pointer? That is, why I can't read/write memory which address is simply 0?

Does the base pointer of my process have a different address? If yes, is there a way to obtain the lower memory adders available for the default heap of my process?

like image 924
Nick Avatar asked May 21 '14 15:05

Nick


2 Answers

A null pointer is not a pointer to "memory [whose] address is simply 0". It's just a special pointer that doesn't point to anything valid.

The C language says that there are no requirements on the behaviour of a program that dereferences a null pointer.

like image 63
R. Martinho Fernandes Avatar answered Sep 23 '22 04:09

R. Martinho Fernandes


Why can't I make a phone call to 00000 000 000? I should be able to do this.

like image 29
Lightness Races in Orbit Avatar answered Sep 22 '22 04:09

Lightness Races in Orbit