memory corruption

前端 未结 7 1132
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-21 19:31

i was running a small c program:

#include
int main()
{
char *p;
p = (char *)malloc(10);
free(p);
free(p);
free(p);
printf(\"\\npointer is freed!!\         


        
7条回答
  •  粉色の甜心
    2021-01-21 19:55

    As per the man page, "if free(ptr) has already been called before, undefined behavior occurs."

    It doesn't need to blow up; "not doing anything" is perfectly acceptable undefined behaviour. Also are nasal demons. Don't rely on it.

提交回复
热议问题