Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 2
    Here is your problem string = argv[1]; You are assigning pointer to something that was not mallocated Commented Jun 11, 2019 at 0:16
  • Have you made sure the pointer to the memory you're trying to reallocate is the same as the pointer you got back when you allocated memory? Commented Jun 11, 2019 at 0:16
  • Note that in C sizeof(char) is guaranteed to be equal to one. Commented Jun 11, 2019 at 0:50
  • How to debug: Huh realloc crash. I get a message saying that the data was not allocated by malloc. So the pointer passed to realloc must be bad. Look at the function call, looks ok. Could there be a problem with malloc? Check the malloc code. And somewhere around there you should hear bells and whistles as you glance upon two adjacent lines in your code, the first one string = malloc ... and the next one string = something else. Commented Jun 11, 2019 at 7:46