[EMAIL PROTECTED] wrote:
Author: gozer
Date: Fri Dec 16 13:20:23 2005
New Revision: 357236
URL: http://svn.apache.org/viewcvs?rev=357236&view=rev
Log:
"local %ENV;" caused Segmentation fault in modperl_env_request_tie()
Reported-By: Peter Walsham <[EMAIL PROTECTED]>
Thread: http://thread.gmane.org/gmane.comp.apache.mod-perl/22236
a bug fix w/o adding a test?
Modified:
perl/modperl/trunk/src/modules/perl/modperl_env.c
Modified: perl/modperl/trunk/src/modules/perl/modperl_env.c
URL:
http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/modperl_env.c?rev=357236&r1=357235&r2=357236&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_env.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_env.c Fri Dec 16 13:20:23 2005
@@ -15,8 +15,13 @@
#include "mod_perl.h"
-#define EnvMgObj SvMAGIC((SV*)ENVHV)->mg_ptr
-#define EnvMgLen SvMAGIC((SV*)ENVHV)->mg_len
+#define EnvMgOK ((SV*)ENVHV && SvMAGIC((SV*)ENVHV))
+#define EnvMgObj (EnvMgOK ? SvMAGIC((SV*)ENVHV)->mg_ptr : NULL)
+#define EnvMgLen (EnvMgOK ? SvMAGIC((SV*)ENVHV)->mg_len : 0)
+#define EnvMgObjSet(val){ \
+ if (EnvMgOK) SvMAGIC((SV*)ENVHV)->mg_ptr = (char *)val;}
+#define EnvMgLenSet(val) {\
+ if (EnvMgOK) SvMAGIC((SV*)ENVHV)->mg_len = val;}
/* XXX: move to utils? */
static unsigned long modperl_interp_address(pTHX)
@@ -401,8 +406,8 @@
void modperl_env_request_tie(pTHX_ request_rec *r)
{
- EnvMgObj = (char *)r;
- EnvMgLen = -1;
+ EnvMgObjSet(r);
+ EnvMgLenSet(-1);
#ifdef MP_PERL_HV_GMAGICAL_AWARE
MP_TRACE_e(MP_FUNC, "[%s/0x%lx] tie %%ENV, $r\n\t (%s%s)",
@@ -414,7 +419,7 @@
void modperl_env_request_untie(pTHX_ request_rec *r)
{
- EnvMgObj = NULL;
+ EnvMgObjSet(NULL);
#ifdef MP_PERL_HV_GMAGICAL_AWARE
MP_TRACE_e(MP_FUNC, "[%s/0x%lx] untie %%ENV; # from r\n\t (%s%s)",
--
_____________________________________________________________
Stas Bekman mailto:[EMAIL PROTECTED] http://stason.org/
MailChannels: Assured Messaging(TM) http://mailchannels.com/
The "Practical mod_perl" book http://modperlbook.org/
http://perl.apache.org/ http://perl.org/ http://logilune.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]