checkbufferoverrun: fixed bug - skip some checks when variable id is unknown (Ticket: 138)

This commit is contained in:
Daniel Marjamäki 2009-03-05 18:28:59 +01:00
parent 4522bcd680
commit 0011d059e6
1 changed files with 2 additions and 2 deletions

View File

@ -257,7 +257,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope(const Token *tok, co
// Dangerous usage of strncat..
if (Token::Match(tok, "strncat ( %varid% , %any% , %num% )", varid))
if (varid > 0 && Token::Match(tok, "strncat ( %varid% , %any% , %num% )", varid))
{
int n = atoi(tok->strAt(6));
if (n == size)
@ -266,7 +266,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope(const Token *tok, co
// Dangerous usage of strncpy + strncat..
if (Token::Match(tok, "strncpy|strncat ( %varid% , %any% , %num% ) ; strncat ( %varid% , %any% , %num% )", varid))
if (varid > 0 && Token::Match(tok, "strncpy|strncat ( %varid% , %any% , %num% ) ; strncat ( %varid% , %any% , %num% )", varid))
{
int n = atoi(tok->strAt(6)) + atoi(tok->strAt(15));
if (n > size)