httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject cvs commit: httpd-apreq-2/glue/perl/xsbuilder apreq_xs_postperl.h
Date Fri, 11 Jun 2004 03:16:26 GMT
joes        2004/06/10 20:16:26

  Modified:    glue/perl/xsbuilder apreq_xs_postperl.h
  Log:
  Revert sv_magic() calls to the pre-5.8 idiom, otherwise a pre-5.8 sv_magic call will mangle
the env pointer (it eventually tries to strcpy env).
  
  Revision  Changes    Path
  1.25      +27 -4     httpd-apreq-2/glue/perl/xsbuilder/apreq_xs_postperl.h
  
  Index: apreq_xs_postperl.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/apreq_xs_postperl.h,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- apreq_xs_postperl.h	13 Apr 2004 00:41:55 -0000	1.24
  +++ apreq_xs_postperl.h	11 Jun 2004 03:16:26 -0000	1.25
  @@ -110,8 +110,19 @@
   static SV *apreq_xs_c2perl(pTHX_ void *obj, void *env, const char *class)
   {
       SV *rv = sv_setref_pv(newSV(0), class, obj);
  -    if (env)
  -        sv_magic(SvRV(rv), Nullsv, PERL_MAGIC_ext, env, 0);
  +    if (env) {
  +        /* We use the old idiom for sv_magic() below,
  +         * because perl 5.6 mangles the env pointer on
  +         * the recommended 5.8.x invocation
  +         *
  +         *   sv_magic(SvRV(rv), Nullsv, PERL_MAGIC_ext, env, 0);
  +         *
  +         * 5.8.x is OK with the old way as well, but in the future
  +         * we may have to use "#if PERL_VERSION < 8" ...
  +         */
  +        sv_magic(SvRV(rv), Nullsv, PERL_MAGIC_ext, Nullch, -1);
  +        SvMAGIC(SvRV(rv))->mg_ptr = env;
  +    }
       return rv;
   }
   
  @@ -128,8 +139,20 @@
   {
       SV *sv = (SV *)newHV();
       SV *rv = sv_setref_pv(newSV(0), class, obj);
  -    if (env)
  -        sv_magic(SvRV(rv), Nullsv, PERL_MAGIC_ext, env, 0);
  +    if (env) {
  +        /* We use the old idiom for sv_magic() below,
  +         * because perl 5.6 mangles the env pointer on
  +         * the recommended 5.8.x invocation
  +         *
  +         *   sv_magic(SvRV(rv), Nullsv, PERL_MAGIC_ext, env, 0);
  +         *
  +         * 5.8.x is OK with the old way as well, but in the future
  +         * we may have to use "#if PERL_VERSION < 8" ...
  +         */
  +        sv_magic(SvRV(rv), Nullsv, PERL_MAGIC_ext, Nullch, -1);
  +        SvMAGIC(SvRV(rv))->mg_ptr = env;
  +#endif
  +    }
   
       sv_magic(sv, rv, PERL_MAGIC_tied, Nullch, 0);
       SvREFCNT_dec(rv); /* corrects SvREFCNT_inc(rv) implicit in sv_magic */
  
  
  

Mime
View raw message