|
|
|
|
|
by thradams
850 days ago
|
|
In cake there is no temporal hole, we cannot reuse the deleted object.
This prevents double free and use after free. int main() {
struct X * owner p = malloc(sizeof(struct X));
p->text = malloc(10);
free(p->text); //object text destroyed
//p->text is on uninitialized state.
//cannot be used (except assignment)
struct X x2 = {0};
*p = x2; //x2 MOVED TO *p
x_delete(p);
|
|