From 0bad3977df40a70c68778ff0514d0ca712fee402 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 14 Nov 2019 17:13:02 +0100 Subject: [PATCH] cov: avoid passing NULL to strstr function When 'str1' would be NULL, there is no point to run 2nd. strstr(). --- tools/pvck.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/pvck.c b/tools/pvck.c index 79fb8fbc7..1c1bbc241 100644 --- a/tools/pvck.c +++ b/tools/pvck.c @@ -420,11 +420,11 @@ static int _dump_all_text(struct cmd_context *cmd, const char *tofile, struct de memset(line, 0, sizeof(line)); _copy_line(str1, line, &len); log_print("%s", line); - } - if ((str2 = strstr(str1, "creation_time = "))) { - memset(line, 0, sizeof(line)); - _copy_line(str2, line, &len); - log_print("%s\n", line); + if ((str2 = strstr(str1, "creation_time = "))) { + memset(line, 0, sizeof(line)); + _copy_line(str2, line, &len); + log_print("%s\n", line); + } } }