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>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1">
|
<arg nr="1">
|
||||||
<not-uninit/>
|
<not-null/>
|
||||||
<minsize type="argvalue" arg="2"/>
|
<minsize type="argvalue" arg="2"/>
|
||||||
</arg>
|
</arg>
|
||||||
<arg nr="2">
|
<arg nr="2">
|
||||||
<not-uninit/>
|
<not-uninit/>
|
||||||
|
<valid>1:</valid>
|
||||||
</arg>
|
</arg>
|
||||||
<formatstr/>
|
<formatstr/>
|
||||||
<arg nr="3">
|
<arg nr="3">
|
||||||
|
@ -3765,9 +3766,6 @@
|
||||||
<not-null/>
|
<not-null/>
|
||||||
<not-uninit/>
|
<not-uninit/>
|
||||||
</arg>
|
</arg>
|
||||||
<arg nr="any">
|
|
||||||
<not-uninit/>
|
|
||||||
</arg>
|
|
||||||
</function>
|
</function>
|
||||||
<!-- int vsnprintf(char *s, size_t n, const char *format, va_list arg); -->
|
<!-- int vsnprintf(char *s, size_t n, const char *format, va_list arg); -->
|
||||||
<function name="vsnprintf,std::vsnprintf">
|
<function name="vsnprintf,std::vsnprintf">
|
||||||
|
|
|
@ -683,6 +683,20 @@ static std::string functionName(const Token *ftok)
|
||||||
return ret;
|
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 */
|
/** get allocation id for function */
|
||||||
int Library::alloc(const Token *tok) const
|
int Library::alloc(const Token *tok) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -217,10 +217,7 @@ public:
|
||||||
return arg && arg->notnull;
|
return arg && arg->notnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isuninitargbad(const Token *ftok, int argnr) const {
|
bool isuninitargbad(const Token *ftok, int argnr) const;
|
||||||
const ArgumentChecks *arg = getarg(ftok, argnr);
|
|
||||||
return arg && arg->notuninit;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isargformatstr(const Token *ftok, int argnr) const {
|
bool isargformatstr(const Token *ftok, int argnr) const {
|
||||||
const ArgumentChecks *arg = getarg(ftok, argnr);
|
const ArgumentChecks *arg = getarg(ftok, argnr);
|
||||||
|
|
Loading…
Reference in New Issue