subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bert Huijben <>
Subject RE: svn commit: r1507044 -
Date Thu, 25 Jul 2013 20:39:23 GMT
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

This patch will allocate the string twice, because hash puts evaluates
its argument twice.

This should use a tempvar or the Apr hash function directly From:
Sent: =E2=80=8E25/=E2=80=8E07/=E2=80=8E2013 18:10
Subject: svn commit: r1507044
- /subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil=
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=20
  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 mem=
  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/s=
--- subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swiguti=
l_pl.c (original)
+++ subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swiguti=
l_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 =3D hv_iternextsv(h, &key, &retlen);
         void *val =3D 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