std.cfg: Improved configuration of std::[w]string::substr(). Do not allow negative length arguments.
This commit is contained in:
parent
17b538210d
commit
7062b0a973
|
@ -6813,6 +6813,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
</arg>
|
</arg>
|
||||||
<arg nr="2" default="0" direction="in">
|
<arg nr="2" default="0" direction="in">
|
||||||
<not-uninit/>
|
<not-uninit/>
|
||||||
|
<valid>0:</valid>
|
||||||
</arg>
|
</arg>
|
||||||
</function>
|
</function>
|
||||||
<function name="std::wstring::substr">
|
<function name="std::wstring::substr">
|
||||||
|
@ -6825,6 +6826,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
</arg>
|
</arg>
|
||||||
<arg nr="2" default="0" direction="in">
|
<arg nr="2" default="0" direction="in">
|
||||||
<not-uninit/>
|
<not-uninit/>
|
||||||
|
<valid>0:</valid>
|
||||||
</arg>
|
</arg>
|
||||||
</function>
|
</function>
|
||||||
<function name="std::basic_string::substr">
|
<function name="std::basic_string::substr">
|
||||||
|
@ -6837,6 +6839,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
</arg>
|
</arg>
|
||||||
<arg nr="2" default="0" direction="in">
|
<arg nr="2" default="0" direction="in">
|
||||||
<not-uninit/>
|
<not-uninit/>
|
||||||
|
<valid>0:</valid>
|
||||||
</arg>
|
</arg>
|
||||||
</function>
|
</function>
|
||||||
<!-- void std::ios::clear (std::ios::iostate state = std::ios::goodbit);-->
|
<!-- void std::ios::clear (std::ios::iostate state = std::ios::goodbit);-->
|
||||||
|
|
|
@ -31,6 +31,26 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
void invalidFunctionArg_std_string_substr(const std::string &str, std::size_t pos, std::size_t len) {
|
||||||
|
// cppcheck-suppress invalidFunctionArg
|
||||||
|
(void)str.substr(-1,len);
|
||||||
|
// cppcheck-suppress invalidFunctionArg
|
||||||
|
(void)str.substr(pos,-1);
|
||||||
|
// no warning is expected for
|
||||||
|
(void)str.substr(pos,len);
|
||||||
|
(void)str.substr(pos, std::wstring::npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void invalidFunctionArg_std_wstring_substr(const std::wstring &str, std::size_t pos, std::size_t len) {
|
||||||
|
// cppcheck-suppress invalidFunctionArg
|
||||||
|
(void)str.substr(-1,len);
|
||||||
|
// cppcheck-suppress invalidFunctionArg
|
||||||
|
(void)str.substr(pos,-1);
|
||||||
|
// no warning is expected for
|
||||||
|
(void)str.substr(pos,len);
|
||||||
|
(void)str.substr(pos, std::string::npos);
|
||||||
|
}
|
||||||
|
|
||||||
double invalidFunctionArg_log10(double d = 0.0) {
|
double invalidFunctionArg_log10(double d = 0.0) {
|
||||||
// cppcheck-suppress invalidFunctionArg
|
// cppcheck-suppress invalidFunctionArg
|
||||||
return log10(d);
|
return log10(d);
|
||||||
|
|
Loading…
Reference in New Issue