diff mbox

[3/7] uri: avoid NULL arguments to strcmp

Message ID 1422270747-23994-4-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Jan. 26, 2015, 11:12 a.m. UTC
Detected by Coverity.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 util/uri.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/util/uri.c b/util/uri.c
index 918d235..014d40d 100644
--- a/util/uri.c
+++ b/util/uri.c
@@ -1971,7 +1971,9 @@  uri_resolve_relative (const char *uri, const char * base)
 	val = g_strdup (uri);
 	goto done;
     }
-    if (!strcmp(bas->path, ref->path)) {
+    if (bas->path == ref->path ||
+        (bas->path != NULL && ref->path != NULL &&
+         !strcmp(bas->path, ref->path))) {
 	val = g_strdup("");
 	goto done;
     }