Save message when calling __DIE__ hook
authorChip Salzenberg <chip@atlantic.net>
Thu, 28 Nov 1996 22:14:29 +0000 (10:14 +1200)
committerChip Salzenberg <chip@atlantic.net>
Fri, 29 Nov 1996 17:31:00 +0000 (05:31 +1200)
pp_ctl.c

index 999b2cc..8a38214 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -932,6 +932,7 @@ die(pat, va_alist)
         dSP;
         SWITCHSTACK(curstack, mainstack);
     }
+
 #ifdef I_STDARG
     va_start(args, pat);
 #else
@@ -939,16 +940,21 @@ die(pat, va_alist)
 #endif
     message = mess(pat, &args);
     va_end(args);
+
     if (diehook && (cv = sv_2cv(diehook, &stash, &gv, 0)) && !CvDEPTH(cv)) {
        dSP;
+       SV *msg = sv_2mortal(newSVpv(message, 0));
 
        PUSHMARK(sp);
        EXTEND(sp, 1);
-       PUSHs(sv_2mortal(newSVpv(message,0)));
+       PUSHs(msg);
        PUTBACK;
        perl_call_sv((SV*)cv, G_DISCARD);
-       message = mess(pat, &args);     /* Static buffer could be reused. */
+
+       /* It's okay for the __DIE__ hook to modify the message. */
+       message = SvPV(msg, na);
     }
+
     restartop = die_where(message);
     if ((!restartop && was_in_eval) || oldrunlevel > 1)
        Siglongjmp(top_env, 3);