[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: JNIUtil.cpp:583: dangling pointer ?

From: Philip Martin <philip.martin_at_wandisco.com>
Date: Fri, 08 May 2015 11:21:27 +0100

David Binderman <dcb314_at_hotmail.com> writes:

> [subversion-1.9.0-beta1/subversion/bindings/javahl/native/JNIUtil.cpp:583]:
> (error) Dangerous usage of c_str(). The value returned by c_str() is
> invalid after this call.
>
>
> #ifdef SVN_DEBUG
> #ifndef SVN_ERR__TRACING
>   if (err->file)
>     {
>       std::ostringstream buf;
>       buf << err->file;
>       if (err->line> 0)
>         buf << ':' << err->line;
>       source = buf.str().c_str();
>     }
> #endif
> #endif
>
> Luckily, it's only debug code, but you might want to fix it anyway.

Yes, that is wrong. How did you find this? I would not expect a
compiler to ever see this bit of code as svn_error.h has:

#ifdef SVN_DEBUG
#define SVN_ERR__TRACING
#endif

I can change that bit of JNIUtil.cpp code to junk and it still builds.

-- 
Philip Martin | Subversion Committer
WANdisco // *Non-Stop Data*
Received on 2015-05-08 12:21:34 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.