perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From go...@apache.org
Subject svn commit: r357236 - /perl/modperl/trunk/src/modules/perl/modperl_env.c
Date Fri, 16 Dec 2005 21:20:26 GMT
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 <peter@axomic.com>
Thread: http://thread.gmane.org/gmane.comp.apache.mod-perl/22236


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)",



Mime
View raw message