3 ms·
I'm not sure it would catch all the double free errors anyway. Imagine a case where we have x_1 = malloc(n) free(x_1) ... x_2 = malloc(n) // ma
by Paul-ish 10y ago
I'm not sure it would catch all the double free errors anyway. Imagine a case where we have
x_1 = malloc(n)
free(x_1)
...
x_2 = malloc(n) // malloc returns the same address as x_1, ie x_1 == x_2
...
free(x_1)
...
example_function(x_2)
How would the runtime know the difference between a double free of x_1 and freeing x_1 then later x_2? And now we think x_2 points to valid data when it doesn't, which can lead to a use after free error.