You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2018/07/27 13:00:44 UTC
svn commit: r1836817 -
/subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp
Author: brane
Date: Fri Jul 27 13:00:44 2018
New Revision: 1836817
URL: http://svn.apache.org/viewvc?rev=1836817&view=rev
Log:
Fix a potential crash in JavaHL.
* subversion/bindings/javahl/native/JNIUtil.cpp
(JNIUtil::wrappedCreateClientException): Don't store an invalid pointer to
out-of-scope std::streambuf contents.
Found by David Binderman
Fixes #4764
Modified:
subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp
Modified: subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp?rev=1836817&r1=1836816&r2=1836817&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp Fri Jul 27 13:00:44 2018
@@ -578,16 +578,17 @@ jthrowable JNIUtil::wrappedCreateClientE
if (JNIUtil::isJavaExceptionThrown())
return NULL;
- const char *source = NULL;
+ std::string source;
#ifdef SVN_DEBUG
#ifndef SVN_ERR__TRACING
if (err->file)
{
- std::ostringstream buf;
- buf << err->file;
+ source = err->file;
if (err->line > 0)
- buf << ':' << err->line;
- source = buf.str().c_str();
+ {
+ source += ':';
+ source += err->line;
+ }
}
#endif
#endif
@@ -615,7 +616,7 @@ jthrowable JNIUtil::wrappedCreateClientE
JNICriticalSection cs(*g_logMutex);
g_logStream << "Subversion JavaHL exception thrown, message:<";
g_logStream << msg << ">";
- if (source)
+ if (!source.empty())
g_logStream << " source:<" << source << ">";
if (err->apr_err != -1)
g_logStream << " apr-err:<" << err->apr_err << ">";
@@ -624,7 +625,7 @@ jthrowable JNIUtil::wrappedCreateClientE
if (isJavaExceptionThrown())
POP_AND_RETURN_NULL;
- jstring jsource = makeJString(source);
+ jstring jsource = (source.empty() ? NULL : makeJString(source.c_str()));
if (isJavaExceptionThrown())
POP_AND_RETURN_NULL;