You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rs...@apache.org on 2013/07/25 18:09:39 UTC

svn commit: r1507044 - /subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c

Author: rschupp
Date: Thu Jul 25 16:09:39 2013
New Revision: 1507044

URL: http://svn.apache.org/r1507044
Log:
Fix a Perl-to-APR conversion function.

* subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c
  (svn_swig_pl_to_hash): This function is the universal converter
  from "Perl hash of some values" to "APR hash of (converted) values".
  It uses hv_iternextsv(H, &KEY, &LEN) to retrieve a Perl 
  hash key. This does _not_ copy the key string, but simply sets KEY
  to a pointer into Perl internal memory. svn_hash_sets() also does _not_
  copy KEY, so the returned apt_hash_t now contains a pointer into Perl memory.
  If Perl later garbage collects this memory this apt_hash_t key will point
  to random bytes and apr_hash_get() for this key will fail.
  Hence make a copy of the string and use that for svn_hash_sets().

Modified:
    subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c

Modified: subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c?rev=1507044&r1=1507043&r2=1507044&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c (original)
+++ subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c Thu Jul 25 16:09:39 2013
@@ -187,7 +187,7 @@ static apr_hash_t *svn_swig_pl_to_hash(S
     while (cnt--) {
         SV* item = hv_iternextsv(h, &key, &retlen);
         void *val = cv(item, ctx, pool);
-        svn_hash_sets(hash, key, val);
+        svn_hash_sets(hash, apr_pstrmemdup(pool, key, retlen), val);
     }
 
     return hash;