Philippe M. Chiasson wrote:
Steve Hay wrote:
The attached patch stops mod_perl-1.x from calling av_undef() on a NULL AV*.
Applied, built and tested just fine on my side.
Only minor comment would be to consider writing a macro around this to
avoid duplicating the code.
#define MP_safe_av_undef(av)
Or something like that.
OK, how about the attached patch instead?
For bonus points, only enable the workaround for affected versions of perl
and fallback to the original av_undef() otherwise.
That's not so easy because it isn't easy to tell what versions of perl
are affected. We could check for perls >= 5.9.5, but that would wrongly
include most versions of bleadperl kicking around between the release of
5.9.4 and the application of change #26513 (not a big problem), and
would also wrongly not include any future 5.8.x releases that change
#26513 might get integrated into. It doesn't seem to me like being worth
the trouble.
The change works fine with older perls, in which av_undef(NULL) is
basically just a no-op anyway.
--
Index: src/modules/perl/mod_perl.c
===================================================================
--- src/modules/perl/mod_perl.c (revision 553409)
+++ src/modules/perl/mod_perl.c (working copy)
@@ -277,14 +277,9 @@
mp_request_rec = 0;
- av_undef(orig_inc);
- SvREFCNT_dec((SV*)orig_inc);
- orig_inc = Nullav;
+ MP_safe_av_undef(orig_inc)
+ MP_safe_av_undef(cleanup_av)
- av_undef(cleanup_av);
- SvREFCNT_dec((SV*)cleanup_av);
- cleanup_av = Nullav;
-
#ifdef PERL_STACKED_HANDLERS
hv_undef(stacked_handlers);
SvREFCNT_dec((SV*)stacked_handlers);
@@ -1159,9 +1154,7 @@
perl_clear_env();
/* reset @INC */
- av_undef(GvAV(incgv));
- SvREFCNT_dec(GvAV(incgv));
- GvAV(incgv) = Nullav;
+ MP_safe_av_undef(GvAV(incgv))
GvAV(incgv) = av_copy_array(orig_inc);
/* reset $/ */
Index: src/modules/perl/mod_perl.h
===================================================================
--- src/modules/perl/mod_perl.h (revision 553409)
+++ src/modules/perl/mod_perl.h (working copy)
@@ -301,6 +301,13 @@
#define av_copy_array(av) av_make(av_len(av)+1, AvARRAY(av))
+#define MP_safe_av_undef(av) \
+if (av != Nullav) { \
+ av_undef(av); \
+ SvREFCNT_dec((SV*)av); \
+ av = Nullav; \
+}
+
#ifndef newRV_noinc
#define newRV_noinc(sv) ((Sv = newRV(sv)), --SvREFCNT(SvRV(Sv)), Sv)
#endif
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]