You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Björn Carlsson <ma...@versionsupport.com> on 2005/03/09 10:59:54 UTC
Corrected bug in StringHelper::endsWith on CVS HEAD
Both
bool StringHelper::endsWith(const std::string& s, const std::string&
suffix)
and
bool StringHelper::endsWith(const std::wstring& s, const
std::wstring& suffix)
should be like this:
return *s*.compare(s.length() - suffix.length(), suffix.length(),
*suffix) *== 0;
and not
return *suffix*.compare(s.length() - suffix.length(),
suffix.length(),* s*) == 0;
--
/Björn Carlsson
VersionSupport.com <http://versionsupport.com>
Re: Corrected bug in StringHelper::endsWith on CVS HEAD
Posted by Curt Arnold <ca...@apache.org>.
On Mar 9, 2005, at 6:01 AM, Björn Carlsson wrote:
> It is checked the row above this row, I quote: "if (suffix.length()
> <= s.length()) {"
>
> And I should be a bit more clear on anopther point to. This is my
> suggestion for solution, I have not commited this code, since I'm not
> a member of the project.
> And I post it here since I'm not a member of
> log4cxx-dev@logging.apache.org. either. If I find more things I want
> to correct, I will consider to find some other way.
>
> /Björn Carlsson
> VersionSupport.com
>
Thanks for both catches. The best way to report bugs and submit
patches is to use the log4cxx JIRA (http://nagoya.apache.org/jira).
I've opened and resolved a Jira bug report (LOGCXX-70) and committed
unit tests for startsWith (which had a different bug) and endsWith and
the corrections.
I'll use the still open LOGCXX-67 bug that added the NTEventLogTestCase
to resolve the other issue.
I've emailed Apache infrastructure about the mailing list archive
problems.
Re: Corrected bug in StringHelper::endsWith on CVS HEAD
Posted by Björn Carlsson <ma...@versionsupport.com>.
It is checked the row above this row, I quote: "if (suffix.length() <=
s.length()) {"
And I should be a bit more clear on anopther point to. This is my
suggestion for solution, I have not commited this code, since I'm not a
member of the project.
And I post it here since I'm not a member of
log4cxx-dev@logging.apache.org <ma...@logging.apache.org>.
either. If I find more things I want to correct, I will consider to find
some other way.
/Björn Carlsson
VersionSupport.com <http://versionsupport.com>
Stoyan Damov wrote:
> If suffix.length() is bigger than s.length() you'll get
> std::out_of_range exception, because s.length() - suffix.length() will
> yield a *very* big value.
> (but I haven't looked at the source code to see whether the arguments
> are being checked by the caller, so sorry for my comment, if that's
> the case)
>
> Cheers,
> Stoyan
>
> -----Original Message-----
> *From:* Bjцrn Carlsson [mailto:maillist@versionsupport.com]
> *Sent:* 03/09/2005 12:00
> *To:* log4cxx-user@logging.apache.org
> *Subject:* Corrected bug in StringHelper::endsWith on CVS HEAD
>
> Both
> bool StringHelper::endsWith(const std::string& s, const
> std::string& suffix)
> and
> bool StringHelper::endsWith(const std::wstring& s, const
> std::wstring& suffix)
> should be like this:
> return *s*.compare(s.length() - suffix.length(),
> suffix.length(), *suffix) *== 0;
>
> and not
> return *suffix*.compare(s.length() - suffix.length(),
> suffix.length(),* s*) == 0;
>
> --
> /Björn Carlsson
> VersionSupport.com <http://versionsupport.com>
>
--
RE: Corrected bug in StringHelper::endsWith on CVS HEAD
Posted by Stoyan Damov <st...@pirinsoft.com>.
If suffix.length() is bigger than s.length() you'll get std::out_of_range exception, because s.length() - suffix.length() will yield a *very* big value.
(but I haven't looked at the source code to see whether the arguments are being checked by the caller, so sorry for my comment, if that's the case)
Cheers,
Stoyan
-----Original Message-----
From: Bjцrn Carlsson [mailto:maillist@versionsupport.com]
Sent: 03/09/2005 12:00
To: log4cxx-user@logging.apache.org
Subject: Corrected bug in StringHelper::endsWith on CVS HEAD
Both
bool StringHelper::endsWith(const std::string& s, const std::string& suffix)
and
bool StringHelper::endsWith(const std::wstring& s, const std::wstring& suffix)
should be like this:
return s.compare(s.length() - suffix.length(), suffix.length(), suffix) == 0;
and not
return suffix.compare(s.length() - suffix.length(), suffix.length(), s) == 0;
--
/Björn Carlsson
VersionSupport.com