From 137a4c6309213ad0e4ee63ac1b3e615d2bcdf382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 6 Apr 2008 11:53:23 +0000 Subject: [PATCH] CheckBufferOverrun: Removed a false positive --- CheckBufferOverrun.cpp | 2 +- tests.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CheckBufferOverrun.cpp b/CheckBufferOverrun.cpp index 9f14851cb..57c3bf60d 100644 --- a/CheckBufferOverrun.cpp +++ b/CheckBufferOverrun.cpp @@ -73,7 +73,7 @@ static void CheckBufferOverrun_CheckScope( const TOKEN *tok, const char *varname } // Array index.. - if ( !IsName(tok->str) && Match(tok->next, "%var1% [ %num% ]", varname) ) + if ( !IsName(tok->str) && tok->str[0] != '.' && Match(tok->next, "%var1% [ %num% ]", varname) ) { const char *num = getstr(tok->next, 2 + varc); if (strtol(num, NULL, 10) >= size) diff --git a/tests.cpp b/tests.cpp index 765b51565..c34b71b31 100644 --- a/tests.cpp +++ b/tests.cpp @@ -307,6 +307,15 @@ static void buffer_overrun() + const char test15[] = "static void f()\n" + "{\n" + " char data[1];\n" + " return abc.data[1];\n" + "}\n"; + check( CheckBufferOverrun, __LINE__, test15, "" ); + + + // TODO