Is this a double free in C?

后端 未结 5 1316
余生分开走
余生分开走 2021-01-13 18:27

Normally, if a pointer is freed twice, it\'s a double free. For example,

char *ptr;
ptr=malloc(5 * sizeof(*ptr));
free(ptr);
free(ptr);

The

5条回答
  •  遥遥无期
    2021-01-13 18:58

    Yes. The library doesn't care what name you gave a varaible in your source code (it's long gone by the time the code is executed). All that matters is the value, and in this case the values passed to free() would be the same.

提交回复
热议问题