[Pkg-libvirt-commits] [libguestfs] 66/266: tests: c-api: do not crash w/ missing hash entry

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:41:43 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.35-1
in repository libguestfs.

commit fef0881b3a31adebf66e0374fed3eb41f9d1471d
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.
---
 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