|
|
RE: Corrected bug in StringHelper::endsWith on CVS HEAD: msg#00024
apache.logging.log4cxx.user
|
Subject: |
RE: Corrected bug in StringHelper::endsWith on CVS HEAD |
|
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
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;
|
| |