diff --git a/lib/library.cpp b/lib/library.cpp index 4d6ae5a4eb3..07270b7e520 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -1512,7 +1512,7 @@ Library::ArgumentChecks::Direction Library::getArgDirection(const Token* ftok, i const ArgumentChecks* arg = getarg(ftok, argnr); if (arg) { if (indirect < 0 || indirect >= arg->direction.size()) - throw InternalError(ftok, "Bad indirect value: " + std::to_string(indirect)); + return ArgumentChecks::Direction::DIR_UNKNOWN; // TODO: don't generate bad indirect values return arg->direction[indirect]; } if (formatstr_function(ftok)) { diff --git a/test/cfg/std.c b/test/cfg/std.c index f795cdc5bda..193339e9a58 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -320,6 +320,15 @@ void bufferAccessOutOfBounds_libraryDirectionConfiguration(void) arr[c] = 'x'; } +void internalError_libraryDirectionConfiguration(char* str) { // #12824 + const char* s = str; + char* end = str; + if (1) { + // cppcheck-suppress unreadVariable + unsigned long val = strtoul(&s[1], &end, 10); + } +} + void arrayIndexOutOfBounds() { char * pAlloc1 = aligned_alloc(8, 16); diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 0e1f205d2cb..d11d9edb42d 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -5070,3 +5070,8 @@ void constVariablePointer_push_back(std::vector& d, const std::vector& s d.push_back(newE); } } + +// cppcheck-suppress constParameterReference +void constParameterReference_push_back(std::vector& v, std::string& s) { // #12661 + v.push_back(s); +}