Fixed #7012 (False positive uninitvar - first argument to snprintf)
This commit is contained in:
parent
a574fda8a9
commit
28e3c266b3
|
@ -3753,11 +3753,12 @@
|
|||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1">
|
||||
<not-uninit/>
|
||||
<not-null/>
|
||||
<minsize type="argvalue" arg="2"/>
|
||||
</arg>
|
||||
<arg nr="2">
|
||||
<not-uninit/>
|
||||
<valid>1:</valid>
|
||||
</arg>
|
||||
<formatstr/>
|
||||
<arg nr="3">
|
||||
|
@ -3765,9 +3766,6 @@
|
|||
<not-null/>
|
||||
<not-uninit/>
|
||||
</arg>
|
||||
<arg nr="any">
|
||||
<not-uninit/>
|
||||
</arg>
|
||||
</function>
|
||||
<!-- int vsnprintf(char *s, size_t n, const char *format, va_list arg); -->
|
||||
<function name="vsnprintf,std::vsnprintf">
|
||||
|
|
|
@ -683,6 +683,20 @@ static std::string functionName(const Token *ftok)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Library::isuninitargbad(const Token *ftok, int argnr) const
|
||||
{
|
||||
const ArgumentChecks *arg = getarg(ftok, argnr);
|
||||
if (!arg) {
|
||||
// non-scan format string argument should not be uninitialized
|
||||
const std::string funcname = functionName(ftok);
|
||||
std::map<std::string, std::pair<bool, bool> >::const_iterator it = _formatstr.find(funcname);
|
||||
if (it != _formatstr.end() && !it->second.first)
|
||||
return true;
|
||||
}
|
||||
return arg && arg->notuninit;
|
||||
}
|
||||
|
||||
|
||||
/** get allocation id for function */
|
||||
int Library::alloc(const Token *tok) const
|
||||
{
|
||||
|
|
|
@ -217,10 +217,7 @@ public:
|
|||
return arg && arg->notnull;
|
||||
}
|
||||
|
||||
bool isuninitargbad(const Token *ftok, int argnr) const {
|
||||
const ArgumentChecks *arg = getarg(ftok, argnr);
|
||||
return arg && arg->notuninit;
|
||||
}
|
||||
bool isuninitargbad(const Token *ftok, int argnr) const;
|
||||
|
||||
bool isargformatstr(const Token *ftok, int argnr) const {
|
||||
const ArgumentChecks *arg = getarg(ftok, argnr);
|
||||
|
|
Loading…
Reference in New Issue