summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2020-04-27 09:13:46 +1000
committerPauli <paul.dale@oracle.com>2020-04-30 20:21:33 +1000
commit61cdc2a08dcd6d4805dab21483974cc82b88d6e3 (patch)
tree64d027306e59ca08641f09e28396563e165d2b22 /apps
parent67d744b933b4f31a5b9a5341f2cfea7535363a88 (diff)
coverity 1462571 Dereference after null check
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/11651)
Diffstat (limited to 'apps')
-rw-r--r--apps/lib/app_x509.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/apps/lib/app_x509.c b/apps/lib/app_x509.c
index 89c5960fa6..00581aabbd 100644
--- a/apps/lib/app_x509.c
+++ b/apps/lib/app_x509.c
@@ -106,12 +106,15 @@ static int do_x509_ctrl_string(int (*ctrl)(void *object, int cmd,
cmd = EVP_PKEY_CTRL_SET1_ID; /* ... except we put it in X509 */
#endif
} else if (strcmp(stmp, "hexdistid") == 0) {
- long hexid_len = 0;
- void *hexid = OPENSSL_hexstr2buf((const char *)vtmp, &hexid_len);
-
- OPENSSL_free(stmp);
- stmp = vtmp = hexid;
- vtmp_len = (size_t)hexid_len;
+ if (vtmp != NULL) {
+ void *hexid;
+ long hexid_len = 0;
+
+ hexid = OPENSSL_hexstr2buf((const char *)vtmp, &hexid_len);
+ OPENSSL_free(stmp);
+ stmp = vtmp = hexid;
+ vtmp_len = (size_t)hexid_len;
+ }
#ifdef EVP_PKEY_CTRL_SET1_ID
cmd = EVP_PKEY_CTRL_SET1_ID; /* ... except we put it in X509 */
#endif