summaryrefslogtreecommitdiff
path: root/cipher/md.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2014-04-15 16:40:48 +0200
committerWerner Koch <wk@gnupg.org>2014-04-15 22:15:11 +0200
commitae1fbce6dacf14747af0126e640bd4e54cb8c680 (patch)
tree6a9db333470556e45b920cd02ce2e7da745089aa /cipher/md.c
parentb76b632a453b8d100d024e2439b4358454dc286e (diff)
downloadlibgcrypt-ae1fbce6dacf14747af0126e640bd4e54cb8c680.tar.gz
cipher: Fix possible NULL dereference.
* cipher/md.c (_gcry_md_selftest): Check for spec being NULL. -- Also removed left-over code in unused file cipher/test-getrusage.c. Found by Hans-Christoph Steiner with cppcheck.
Diffstat (limited to 'cipher/md.c')
-rw-r--r--cipher/md.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/cipher/md.c b/cipher/md.c
index 461ad642..5ab89cbd 100644
--- a/cipher/md.c
+++ b/cipher/md.c
@@ -1250,7 +1250,8 @@ _gcry_md_selftest (int algo, int extended, selftest_report_func_t report)
ec = spec->selftest (algo, extended, report);
else
{
- ec = spec->selftest? GPG_ERR_DIGEST_ALGO : GPG_ERR_NOT_IMPLEMENTED;
+ ec = (spec && spec->selftest) ? GPG_ERR_DIGEST_ALGO
+ /* */ : GPG_ERR_NOT_IMPLEMENTED;
if (report)
report ("digest", algo, "module",
(spec && !spec->flags.disabled)?