Author: brane
Date: Thu Jul 25 14:25:28 2013
New Revision: 1506983
URL: http://svn.apache.org/r1506983
Log:
Fix a crash in JavaHL caused by double-free that was the result of ambiguous
object ownership. Not using smart pointers makes life more interesting.
* subversion/bindings/javahl/native/RemoteSession.h
(RemoteSession::open, RemoteSession::RemoteSession): Change the prompter
parameter to a reference to a pointer.
* subversion/bindings/javahl/native/RemoteSession.cpp
(RemoteSession::open): Update to changed prototype.
(RemoteSession::RemoteSession): As above, and set the caller's copy of
the prompter pointer to NULL to avoid double-free.
Modified:
subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp
subversion/trunk/subversion/bindings/javahl/native/RemoteSession.h
Modified: subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp?rev=1506983&r1=1506982&r2=1506983&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp
(original)
+++ subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp Thu
Jul 25 14:25:28 2013
@@ -125,7 +125,7 @@ RemoteSession::open(jint jretryAttempts,
const char* url, const char* uuid,
const char* configDirectory, jobject jconfigHandler,
const char* usernameStr, const char* passwordStr,
- Prompter* prompter, jobject jprogress)
+ Prompter*& prompter, jobject jprogress)
{
/*
* Initialize ra layer if we have not done so yet
@@ -168,7 +168,7 @@ RemoteSession::RemoteSession(jobject* jt
const char* configDirectory,
jobject jconfigHandler,
const char* username, const char* password,
- Prompter* prompter, jobject jprogress)
+ Prompter*& prompter, jobject jprogress)
: m_session(NULL), m_context(NULL)
{
// Create java session object
@@ -198,6 +198,14 @@ RemoteSession::RemoteSession(jobject* jt
if (JNIUtil::isJavaExceptionThrown())
return;
+ // Avoid double-free in RemoteSession::open and
+ // SVNClient::openRemoteSession if the svn_ra_open call fails. The
+ // prompter object is now owned by m_context.
+ //
+ // FIXME: Should be using smart pointers, really -- but JavaHL
+ // currently doesn't. Future enhancements FTW.
+ prompter = NULL;
+
const char* corrected_url = NULL;
bool cycle_detected = false;
attempt_set attempted;
Modified: subversion/trunk/subversion/bindings/javahl/native/RemoteSession.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/RemoteSession.h?rev=1506983&r1=1506982&r2=1506983&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/RemoteSession.h
(original)
+++ subversion/trunk/subversion/bindings/javahl/native/RemoteSession.h Thu Jul
25 14:25:28 2013
@@ -55,7 +55,7 @@ class RemoteSession : public SVNBase
const char* configDirectory,
jobject jconfigHandler,
const char* username, const char* password,
- Prompter* prompter, jobject jprogress);
+ Prompter*& prompter, jobject jprogress);
~RemoteSession();
void cancelOperation() const { m_context->cancelOperation(); }
@@ -113,7 +113,7 @@ class RemoteSession : public SVNBase
const char* configDirectory,
jobject jconfigHandler,
const char* username, const char* password,
- Prompter* prompter, jobject jprogress);
+ Prompter*& prompter, jobject jprogress);
svn_ra_session_t* m_session;
RemoteSessionContext* m_context;