Y
Hacker News
new
|
ask
|
show
|
jobs
by
htfy96
2402 days ago
An example to detect use-after-free:
https://godbolt.org/z/zhiNLW
Basically this replicates what clang-tidy did
1 comments
cornstalks
2402 days ago
Too bad it doesn't detect the mismatch between new and free.
link
peapicker
2402 days ago
And if you fix it to use delete instead of free, you get "can't delete void *" errors. Perhaps not the best example code.
link
gpderetta
2402 days ago
and if you fix the void->int, the warning goes away.
link
htfy96
2402 days ago
yeah that's why I changed int* to void* in the example, but I forgot to change new to malloc
link