You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Bert Huijben <be...@qqmail.nl> on 2013/11/21 03:11:48 UTC

Re: svn commit: r1543985 - in /subversion/trunk/subversion/bindings/javahl: native/ native/jniwrapper/ src/org/apache/subversion/javahl/types/ src/org/apache/subversion/javahl/util/ tests/org/apache/subversion/javahl/

Branko,


I might have found the cause of the error. See snippet below


Bert





Sent from Windows Mail





From: Branko Čibej
Sent: ‎Thursday‎, ‎November‎ ‎21‎, ‎2013 ‎12‎:‎43‎ ‎AM
To: commits@subversion.apache.org


+class KeywordHashBuilder
+{
+public:
+  explicit KeywordHashBuilder(const SVN::Pool& pool)
+    : m_pool(pool),
+      m_hash(apr_hash_make(pool.getPool()))
+    {}
+
+  void operator()(const std::string& key, const Java::ByteArray& value)
+    {
+      Java::ByteArray::Contents val(value);
+      apr_hash_set(m_hash, key.c_str(), key.size(), val.get_string(m_pool));
+    }

<<<<<<<

The key must be duplicated in the pool, or hash lookups will look into memory with unknown lifetime when they compare the key.

<<<<<<<


+
+  apr_hash_t* get() const
+    {
+      return m_hash;
+    }
+
+private:
+  const SVN::Pool& m_pool;
+  apr_hash_t* const m_hash;
+};
+

Re: svn commit: r1543985 - in /subversion/trunk/subversion/bindings/javahl: native/ native/jniwrapper/ src/org/apache/subversion/javahl/types/ src/org/apache/subversion/javahl/util/ tests/org/apache/subversion/javahl/

Posted by Branko Čibej <br...@wandisco.com>.
On 21.11.2013 03:11, Bert Huijben wrote:
> Branko,
>
> I might have found the cause of the error. See snippet below

Ouch. Thanks for the review; and of course you're right.

-- Brane


> *From:* Branko Čibej <ma...@apache.org>
> *Sent:* ‎Thursday‎, ‎November‎ ‎21‎, ‎2013 ‎12‎:‎43‎ ‎AM
> *To:* commits@subversion.apache.org <ma...@subversion.apache.org>
>
> +class KeywordHashBuilder
> +{
> +public:
> +  explicit KeywordHashBuilder(const SVN::Pool& pool)
> +    : m_pool(pool),
> +      m_hash(apr_hash_make(pool.getPool()))
> +    {}
> +
> +  void operator()(const std::string& key, const Java::ByteArray& value)
> +    {
> +      Java::ByteArray::Contents val(value);
> +      apr_hash_set(m_hash, key.c_str(), key.size(),
> val.get_string(m_pool));
> +    }
> <<<<<<<
> The key must be duplicated in the pool, or hash lookups will look into
> memory with unknown lifetime when they compare the key.
> <<<<<<<
>
> +
> +  apr_hash_t* get() const
> +    {
> +      return m_hash;
> +    }
> +
> +private:
> +  const SVN::Pool& m_pool;
> +  apr_hash_t* const m_hash;
> +};
> +
>


-- 
Branko Čibej | Director of Subversion
WANdisco // Non-Stop Data
e. brane@wandisco.com