diff options
author | Andre Heinecke <[email protected]> | 2017-01-17 14:20:56 +0000 |
---|---|---|
committer | Andre Heinecke <[email protected]> | 2017-01-17 14:20:56 +0000 |
commit | ca69df8c8d3f044340aee2a118cc20d33cd600a1 (patch) | |
tree | 7267a19a532a8fc730a30d16a47649ac064ca36d /tests | |
parent | qt: Use QVERIFY instead of Q_ASSERT in conf test (diff) | |
download | gpgme-ca69df8c8d3f044340aee2a118cc20d33cd600a1.tar.gz gpgme-ca69df8c8d3f044340aee2a118cc20d33cd600a1.zip |
tests: Add safeguards against nullptr deref
* t-gpgconf.c (main): Test some values before dereferencing them.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gpg/t-gpgconf.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/gpg/t-gpgconf.c b/tests/gpg/t-gpgconf.c index d199d2eb..52f0f8b9 100644 --- a/tests/gpg/t-gpgconf.c +++ b/tests/gpg/t-gpgconf.c @@ -309,9 +309,10 @@ main (void) fail_if_err (err); if (lookup (conf, "dirmngr", "verbose", &comp, &opt)) { - /* Found. */ - test (opt->alt_type == GPGME_CONF_NONE); - test ((unsigned long) opt->value->value.count == count); + /* Found. */ + test (opt->alt_type == GPGME_CONF_NONE); + test (opt->value); + test ((unsigned long) opt->value->value.count == count); } fprintf (stderr, "."); @@ -350,9 +351,11 @@ main (void) fail_if_err (err); if (lookup (conf, "gpg", "keyserver", &comp, &opt)) { - /* Found. */ - test (opt->alt_type == GPGME_CONF_STRING); - test (strcmp (opt->value->value.string, values[i%2]) == 0); + /* Found. */ + test (opt->alt_type == GPGME_CONF_STRING); + test (opt->value); + test (opt->value->value.string); + test (strcmp (opt->value->value.string, values[i%2]) == 0); } fprintf (stderr, "."); |