Skip to content

Commit 99674e1

Browse files
Fix #12824 internalError due to bad indirect value (#6497)
1 parent 1638831 commit 99674e1

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

lib/library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ Library::ArgumentChecks::Direction Library::getArgDirection(const Token* ftok, i
15121512
const ArgumentChecks* arg = getarg(ftok, argnr);
15131513
if (arg) {
15141514
if (indirect < 0 || indirect >= arg->direction.size())
1515-
throw InternalError(ftok, "Bad indirect value: " + std::to_string(indirect));
1515+
return ArgumentChecks::Direction::DIR_UNKNOWN; // TODO: don't generate bad indirect values
15161516
return arg->direction[indirect];
15171517
}
15181518
if (formatstr_function(ftok)) {

test/cfg/std.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,15 @@ void bufferAccessOutOfBounds_libraryDirectionConfiguration(void)
320320
arr[c] = 'x';
321321
}
322322

323+
void internalError_libraryDirectionConfiguration(char* str) { // #12824
324+
const char* s = str;
325+
char* end = str;
326+
if (1) {
327+
// cppcheck-suppress unreadVariable
328+
unsigned long val = strtoul(&s[1], &end, 10);
329+
}
330+
}
331+
323332
void arrayIndexOutOfBounds()
324333
{
325334
char * pAlloc1 = aligned_alloc(8, 16);

test/cfg/std.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5070,3 +5070,8 @@ void constVariablePointer_push_back(std::vector<T*>& d, const std::vector<T*>& s
50705070
d.push_back(newE);
50715071
}
50725072
}
5073+
5074+
// cppcheck-suppress constParameterReference
5075+
void constParameterReference_push_back(std::vector<std::string>& v, std::string& s) { // #12661
5076+
v.push_back(s);
5077+
}

0 commit comments

Comments
 (0)