From 60428c2b10ccec13afe901d21b87ac949ffafa4c Mon Sep 17 00:00:00 2001 From: Kyungwook Tak Date: Wed, 7 Sep 2016 14:56:45 +0900 Subject: [PATCH] Fix svace defects using assert() to check null is good for development but if it is used partly (using both of assert() and if condition) SVACE system detects it as defect because to checking it by if condition means there is probability that it could be null. So we should choose only one of them(To use assert() or if condition) on entire of code. Change-Id: I0da13027c650e11f88f5b06fa35d8f86d43ee879 Signed-off-by: Kyungwook Tak --- src/encrypt.c | 3 ++- src/rsa.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/encrypt.c b/src/encrypt.c index 537fe42..56b316f 100644 --- a/src/encrypt.c +++ b/src/encrypt.c @@ -530,7 +530,8 @@ static int encrypt_ctx_restore(struct yaca_encrypt_context_s *c) } key = key_get_simple(c->backup_ctx->sym_key); - assert(key != NULL); + if (key == NULL) + return YACA_ERROR_INVALID_PARAMETER; ret = encrypt_ctx_init(c, c->backup_ctx->cipher, key->bit_len); assert(ret != YACA_ERROR_INVALID_PARAMETER); diff --git a/src/rsa.c b/src/rsa.c index bf7e21a..277af34 100644 --- a/src/rsa.c +++ b/src/rsa.c @@ -78,7 +78,8 @@ static int encrypt_decrypt(yaca_padding_e padding, assert(lpadding != -1); lasym_key = key_get_evp(key); - assert(lasym_key != NULL); + if (lasym_key == NULL) + return YACA_ERROR_INVALID_PARAMETER; ret = EVP_PKEY_size(lasym_key->evp); if (ret <= 0) { -- 2.7.4