/subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c 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: [email protected] Sent: =E2=80=8E25/=E2=80=8E07/=E2=80=8E2013 18:10 To: [email protected] Subject: 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=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= ory. 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/swiguti= l_pl.c Modified: subversion/trunk/subversion/bindings/swig/perl/libsvn_swig_perl/s= wigutil_pl.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig= /perl/libsvn_swig_perl/swigutil_pl.c?rev=3D1507044&r1=3D1507043&r2=3D150704= 4&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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); } =20 return hash;
