Skip to content

Commit c7705f6

Browse files
gpu/utils: fix null pointer arithmetic in mp_log_source()
strchr() can return NULL when no newline is found. next was computed as end + 1 before the null check, which is undefined behaviour. Moved next assignment after the null check.
1 parent e2180e5 commit c7705f6

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

video/out/gpu/utils.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,11 @@ void mp_log_source(struct mp_log *log, int lev, const char *src)
339339
return;
340340
while (*src) {
341341
const char *end = strchr(src, '\n');
342-
const char *next = end + 1;
342+
const char *next;
343343
if (!end)
344344
next = end = src + strlen(src);
345+
else
346+
next = end + 1;
345347
mp_msg(log, lev, "[%3d] %.*s\n", line, (int)(end - src), src);
346348
line++;
347349
src = next;

0 commit comments

Comments
 (0)