Comment
Comment by t43562
In C I just used goto - you put a cleanup section at the bottom of your code and your error handling just jumps to it.
The advantage being that you never have to remember which things are to be freed at which particular error state. The style also avoids lots of nesting because it returns early. It's not as nice as having defer but it does help in larger functions.