]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: avoid possible null pointer dereference [cppcheck]
authorSami Kerola <kerolasa@iki.fi>
Sat, 18 May 2019 21:14:20 +0000 (22:14 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 18 May 2019 21:17:10 +0000 (22:17 +0100)
[libmount/src/monitor.c:797]: (warning) Possible null pointer dereference: me

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
libmount/src/monitor.c

index 2383a734af4010088796bc514f0309fa68091be0..730c8bdea4e8c5d34b0305d4c82b321ddb6d3330 100644 (file)
@@ -794,14 +794,17 @@ int mnt_monitor_next_change(struct libmnt_monitor *mn,
                        me = NULL;
        }
 
-       me->changed = 0;
+       if (me) {
+               me->changed = 0;
 
-       if (filename)
-               *filename = me->path;
-       if (type)
-               *type = me->type;
+               if (filename)
+                       *filename = me->path;
+               if (type)
+                       *type = me->type;
 
-       DBG(MONITOR, ul_debugobj(mn, " *** success [changed: %s]", me->path));
+               DBG(MONITOR, ul_debugobj(mn, " *** success [changed: %s]", me->path));
+       } else
+               return -EINVAL;
        return 0;                               /* success */
 }