You can only longjmp()
back up the call stack. The call to longjmp(b_buf, 1)
is where things start to go wrong, because the stack frame referenced by b_buf
no longer exists after the longjmp(a_buf)
.
From the documentation for longjmp
:
The longjmp() routines may not be called after the routine which called the setjmp() routines returns.
This includes “returning” through a longjmp()
out of the function.