]> sourceware.org Git - lvm2.git/commitdiff
cov: avoid passing NULL to strstr function
authorZdenek Kabelac <zkabelac@redhat.com>
Thu, 14 Nov 2019 16:13:02 +0000 (17:13 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Thu, 14 Nov 2019 17:06:42 +0000 (18:06 +0100)
When 'str1' would be NULL, there is no point to run 2nd. strstr().

tools/pvck.c

index 79fb8fbc7bd99d82d5c885c977459f795477ff55..1c1bbc2413130910bc3be43a38aef93c364b8cd4 100644 (file)
@@ -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);
+                               }
                        }
                }
 
This page took 0.038476 seconds and 5 git commands to generate.