Opened 4 years ago
Closed 4 years ago
#11179 closed defect (fixed)
FP invalidFunctionArgStr
| Reported by: | chrchr | Owned by: | noone |
|---|---|---|---|
| Priority: | Normal | Milestone: | 2.9 |
| Component: | False positive | Version: | |
| Keywords: | invalidFunctionArgStr | Cc: |
Description (last modified by )
From ocproxy-1.60/contrib/ports/old/coldfire/sys_arch.c:
void f(int num_thread) {
char thread_name[8] = " ";
num_thread = (num_thread +1) % 100;
sprintf(thread_name, "lwip%02d", num_thread);
thread_name[strlen(thread_name)] = ' ';
}
test.cpp:6:24: error: Invalid strlen() argument nr 1. A nul-terminated string is required. [invalidFunctionArgStr]
thread_name[strlen(thread_name)] = ' ';
^
The string is no longer null-terminated after the last line, but still is when strlen() is called.
Tested with https://github.com/danmar/cppcheck/commit/b51aea5531a1eeb49f6dad160142312186e375bc.
Change History (2)
comment:1 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 4 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Fixed by https://github.com/danmar/cppcheck/pull/4264