I have a function
void *srealloc(void * ptr , int size){
void *tmp = realloc(ptr , size);
if(tmp == NULL){
fprintf(stderr,"realloc of %u bytes failed", size);
exit(1);
}
return tmp;
}
My code that calls this runs fine on an x86 computer, but when I compile and run the same code on my x64 computer I get a segfault.
An example of how this is being called is:
line = "Some string";
buffer = (char**) srealloc (buffer,sizeof(buffer)*(++buffer_lines));
buffer[buffer_lines-1] = line;
When I trace through with gdb when srealloc is called on the segfaulting computer ptr == 0x0, size == 8
*Edit: The segfault occurs on:
void *tmp = realloc(ptr, size);