From cbcedf6ba83b0929ad21e227db62883886d2ccce Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 18 May 2019 22:14:20 +0100 Subject: libmount: avoid possible null pointer dereference [cppcheck] [libmount/src/monitor.c:797]: (warning) Possible null pointer dereference: me Signed-off-by: Sami Kerola --- libmount/src/monitor.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'libmount/src') diff --git a/libmount/src/monitor.c b/libmount/src/monitor.c index 2383a734a..730c8bdea 100644 --- a/libmount/src/monitor.c +++ b/libmount/src/monitor.c @@ -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 */ } -- cgit v1.2.3-55-g7522