indent(1): Fix off-by-one in control flow leading dead code.
Coverity correctly reported that it's impossible for /comparison/ to be 0 here, because the only way for the for loop to end is by /comparison/ being < 0. Fortunately the consequences of this bug weren't severe; for duplicated entries in the typedef names file it would unnecessarily duplicate strings with strdup(), but pointers to those would replace existing ones. So this was a memory leak at worst. CID: 1361477 Obtained from: Piotr Stephaniak
This commit is contained in:
parent
6ff6aea629
commit
8e7c1235ce
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=304653
@ -613,7 +613,7 @@ add_typename(const char *key)
|
||||
else {
|
||||
int p;
|
||||
|
||||
for (p = 0; (comparison = strcmp(key, typenames[p])) >= 0; p++)
|
||||
for (p = 0; (comparison = strcmp(key, typenames[p])) > 0; p++)
|
||||
/* find place for the new key */;
|
||||
if (comparison == 0) /* remove duplicates */
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user