Skip to content

Commit 305e82c

Browse files
authored
Fix potential invalid array access in gotcha_strnlen (#162)
Fixes potential invalid array access in `gotcha_strnlen`. See LLNL/Caliper#640
1 parent b56462a commit 305e82c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libc_wrappers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ size_t gotcha_strlen(const char *s) {
191191

192192
size_t gotcha_strnlen(const char *s, size_t max_length) {
193193
size_t i = 0;
194-
for (i = 0; s[i] && i < max_length; i++)
194+
for (i = 0; i < max_length && s[i]; i++)
195195
;
196196
return i;
197197
}

0 commit comments

Comments
 (0)