diff --git a/src/checkbufferoverrun.cpp b/src/checkbufferoverrun.cpp index 7c950651f..e7da7f057 100644 --- a/src/checkbufferoverrun.cpp +++ b/src/checkbufferoverrun.cpp @@ -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)