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

后端 未结 14 1089
天命终不由人
天命终不由人 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条回答
  •  旧时难觅i
    2020-12-09 08:33

    Don't do that. If the memory that got freed is re-allocated to something else between the calls to free, then things will get messed up.

提交回复
热议问题