Skip to content

Commit e7bb1fe

Browse files
committed
examples: avoid passing signed integer to memchr
The memchr(3P) function expects a `size_t` as its last parameter, but we do pass it an object size, which is of signed type `git_off_t`. As we can be sure that the result will be non-negative, let's just cast the parameter to a `size_t`.
1 parent 976eed8 commit e7bb1fe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int lg2_blame(git_repository *repo, int argc, char *argv[])
9191
i = 0;
9292
break_on_null_hunk = 0;
9393
while (i < rawsize) {
94-
const char *eol = memchr(rawdata + i, '\n', rawsize - i);
94+
const char *eol = memchr(rawdata + i, '\n', (size_t)(rawsize - i));
9595
char oid[10] = {0};
9696
const git_blame_hunk *hunk = git_blame_get_hunk_byline(blame, line);
9797

0 commit comments

Comments
 (0)