]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: fix possible null dereferencing [coverity scan]
authorKarel Zak <kzak@redhat.com>
Mon, 30 Jan 2012 22:22:53 +0000 (23:22 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 30 Jan 2012 22:22:53 +0000 (23:22 +0100)
 ... let's keep Coverity analyzer happy.

Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context.c

index 4494ac6c1ecbae8d3106cbd7ed9a0184e7a126c5..2d88dc38e846d95436fbb42489f52f22fa4dd46f 100644 (file)
@@ -1348,7 +1348,9 @@ int mnt_context_prepare_helper(struct libmnt_context *cxt, const char *name,
                rc = stat(helper, &st);
                if (rc == -1 && errno == ENOENT && strchr(type, '.')) {
                        /* If type ends with ".subtype" try without it */
-                       *strrchr(helper, '.') = '\0';
+                       char *hs = strrchr(helper, '.');
+                       if (hs)
+                               *hs = '\0';
                        rc = stat(helper, &st);
                }