Skip to contentSkip to conversation

qemu-ga: Fix null pointer passed to unlink in failure branch

PATCH Applied Stefan Weil 3 participants 3 messages Aug 24, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-ga: Fix null pointer passed to unlink in failure branch

Clang reports this warning:

Null pointer passed as an argument to a 'nonnull' parameter

---
 qemu-ga.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
qemu-ga.c +3 -1
index 26671fe..7623079 100644
@@ -438,7 +438,9 @@ static void become_daemon(const char *pidfile)
     return;
 
 fail:
-    unlink(pidfile);
+    if (pidfile) {
+        unlink(pidfile);
+    }
     g_critical("failed to daemonize");
     exit(EXIT_FAILURE);
 #endif
Signature · 1 line
1.7.10
Reviewed-by on v1 1/1
#2 lore raw
In reply to Stefan Weil
Quoted 5 lines · On Fri, 24 Aug 2012 07:03:03 +0200 Stefan Weil <[email protected]> wrote:

Clang reports this warning:

Null pointer passed as an argument to a 'nonnull' parameter

Quoted 19 lines
---
 qemu-ga.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
qemu-ga.c +3 -1
index 26671fe..7623079 100644
@@ -438,7 +438,9 @@ static void become_daemon(const char *pidfile)
     return;
 
 fail:
-    unlink(pidfile);
+    if (pidfile) {
+        unlink(pidfile);
+    }
     g_critical("failed to daemonize");
     exit(EXIT_FAILURE);
 #endif