dmesg: make strtok() use more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2019-05-23 14:18:29 +02:00
parent 106bd306a4
commit 2d27898844
1 changed files with 3 additions and 0 deletions

View File

@ -1017,6 +1017,8 @@ full_output:
if (!line) {
mesg_copy = xstrdup(rec->mesg);
line = strtok(mesg_copy, "\n");
if (!line)
goto done; /* only when something is wrong */
mesg_size = strlen(line);
}
} else {
@ -1057,6 +1059,7 @@ full_output:
free(mesg_copy);
}
done:
putchar('\n');
}