are you using malloc or realloc on pointer you've defined before it?