tests: Add safeguards against nullptr deref
* t-gpgconf.c (main): Test some values before dereferencing them.
This commit is contained in:
parent
abfd241d1a
commit
ca69df8c8d
@ -311,6 +311,7 @@ main (void)
|
|||||||
{
|
{
|
||||||
/* Found. */
|
/* Found. */
|
||||||
test (opt->alt_type == GPGME_CONF_NONE);
|
test (opt->alt_type == GPGME_CONF_NONE);
|
||||||
|
test (opt->value);
|
||||||
test ((unsigned long) opt->value->value.count == count);
|
test ((unsigned long) opt->value->value.count == count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,6 +353,8 @@ main (void)
|
|||||||
{
|
{
|
||||||
/* Found. */
|
/* Found. */
|
||||||
test (opt->alt_type == GPGME_CONF_STRING);
|
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);
|
test (strcmp (opt->value->value.string, values[i%2]) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user