[Pkg-libvirt-commits] [libguestfs] 122/156: tests: c-api: do not crash w/ missing hash entry
    Hilko Bengen 
    bengen at moszumanska.debian.org
       
    Sat Aug 30 08:26:12 UTC 2014
    
    
  
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch master
in repository libguestfs.
commit 64ba36bb3355ab9ca45ded726edfebb3d19a3c87
Author: Pino Toscano <ptoscano at redhat.com>
Date:   Fri Aug 8 14:56:27 2014 +0200
    tests: c-api: do not crash w/ missing hash entry
    
    If an hash does not have the requested key, just error out cleanly
    instead of crashing when trying to compare a null string.
    
    (cherry picked from commit fef0881b3a31adebf66e0374fed3eb41f9d1471d)
---
 tests/c-api/tests-main.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/tests/c-api/tests-main.c b/tests/c-api/tests-main.c
index 49d36b9..e2e86f5 100644
--- a/tests/c-api/tests-main.c
+++ b/tests/c-api/tests-main.c
@@ -321,6 +321,11 @@ check_hash (char **ret, const char *key, const char *expected)
 {
   const char *value = get_key (ret, key);
 
+  if (value == NULL) {
+    fprintf (stderr, "test failed: hash key %s not found\n", key);
+    return -1;
+  }
+
   if (STRNEQ (value, expected)) {
     fprintf (stderr, "test failed: hash key %s = \"%s\" is not expected value \"%s\"\n",
              key, value, expected);
-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
    
    
More information about the Pkg-libvirt-commits
mailing list