News for hackers. Stuff that matters.
Re:Ode to the use-after-free: one vulnerable function, a tho... by TheSoftwareGuy on Monday May 08, 2017 @01:06PM (#14293467)
Except this won't work when multiple pointers exist to the same data.. which is arguably when this kind of stuff is most difficult
Re:Ode to the use-after-free: one vulnerable function, a tho... by lossolo on Monday May 08, 2017 @01:40PM (#14293781)
If you have multiple pointers to the same data with different lifetimes you already need some kind of reference counting or garbage collection.
Re:Ode to the use-after-free: one vulnerable function, a tho... by pornel on Monday May 08, 2017 @02:05PM (#14294038)
Not necessarily. It's safe if lifetimes of the other pointers are guaranteed to be shorter than the lifetime of the object.
Re:Ode to the use-after-free: one vulnerable function, a tho... by lossolo on Monday May 08, 2017 @02:50PM (#14294411)
That's why I wrote "with different lifetimes".
Re:Ode to the use-after-free: one vulnerable function, a tho... by ktRolster on Monday May 08, 2017 @02:44PM (#14294367)
That's why "safer" :)

It works in the vast majority of cases. In the rare other cases, you should spend some extra thought on your pointer usage to make sure you have a set of abstractions that let a human reason about the memory sensibly (either that or an insane number of test cases to catch any problem). Someone else mentioned reference counting, and that can be a good idea.

The bottom line is you need to do something to make sure you're not doing use-after-free, and it's mostly not difficult.

Re:Ode to the use-after-free: one vulnerable function, a tho... by marcosdumay on Monday May 08, 2017 @06:00PM (#14296028)
It works on most cases that people normally get right, and is useless on most cases that people normally get wrong.

Overall, it's not useless, but it's really not worth modifying the language for it.