What happens when you try to free() already freed memory in c?

后端 未结 14 1093
天命终不由人
天命终不由人 2020-12-09 08:19

For example:

char * myString = malloc(sizeof(char)*STRING_BUFFER_SIZE);
free(myString);
free(myString);

Are there any adverse side effects

14条回答
  •  醉话见心
    2020-12-09 08:30

    Yes, you can get a double free error that causes your program to crash. It has to do with malloc's internal data structures to keep track of allocated memory.

提交回复
热议问题