News for hackers. Stuff that matters.
Re:My Thoughts on “Bad Code” by Someone on Friday March 17, 2023 @08:33AM (#35196247)
I think that dates back to assembly where you have to clear up a stack frame before returning.

Especially when the code to do that depends on the amount of locals, having only a single place where you assign space for locals and a single one where you revert that helps a lot.

It also can help in languages that don’t help you run cleanup code (closing files, freeing memory) at function exit. Change the code and forget to update one of your early exits, and you have a bug. If that exit is rare, that may ship and may become a vulnerability.

Re:My Thoughts on “Bad Code” by Measter on Friday March 17, 2023 @09:18AM (#35196691)
Additionally, something that is forgotten now that structured programming won so hard, and so little assembly is hand-written, is that it's possible to return to different places. As in, in case A return to address F, but in case B return to address G.
Re:My Thoughts on “Bad Code” by deckard1 on Friday March 17, 2023 @12:40PM (#35199441)
The Linux kernel still uses centralized exits in places, with goto to do cleanup.

https://github.com/torvalds/linux/blob/master/Documentation/...