]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/path: fix possible NULL dereferencing [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 15 May 2019 13:57:09 +0000 (15:57 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 15 May 2019 13:57:09 +0000 (15:57 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/path.c

index 9b05f4b98a218e61d9b5cebbfd7a363a193cb9db..6922e27704ccfec2a3ec84020fdd5c0345bdb23b 100644 (file)
@@ -570,10 +570,12 @@ int ul_path_read_string(struct path_cxt *pc, char **str, const char *path)
        char buf[BUFSIZ];
        int rc;
 
-       *str = NULL;
+       if (!str)
+               return -EINVAL;
 
+       *str = NULL;
        rc = ul_path_read(pc, buf, sizeof(buf) - 1, path);
-       if (rc < 0 || !str)
+       if (rc < 0)
                return rc;
 
        /* Remove tailing newline (usual in sysfs) */