subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r1507044 - /subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c
Date Thu, 25 Jul 2013 16:09:39 GMT
Author: rschupp
Date: Thu Jul 25 16:09:39 2013
New Revision: 1507044

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
--- 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;

View raw message