diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2020-09-14 11:35:33 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2020-09-14 11:35:33 +0000 |
commit | 3e5ec706ae6f5bef51ba1cdc783ea4dba0bfb9b9 (patch) | |
tree | cc0ff278e1a9cc1122663887f130856a1098114e | |
parent | 5a7efb52ceb299c56ae984c1f8e8b18a92200fa3 (diff) |
Fix potential leak when tmpext fails to be added to
the extension list.
found by llvm static analyzer
ok tb@
-rw-r--r-- | lib/libcrypto/x509/x509_lib.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libcrypto/x509/x509_lib.c b/lib/libcrypto/x509/x509_lib.c index 3af090fde66..211d0adfeec 100644 --- a/lib/libcrypto/x509/x509_lib.c +++ b/lib/libcrypto/x509/x509_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_lib.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ +/* $OpenBSD: x509_lib.c,v 1.2 2020/09/14 11:35:32 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -168,7 +168,11 @@ X509V3_EXT_add_alias(int nid_to, int nid_from) *tmpext = *ext; tmpext->ext_nid = nid_to; tmpext->ext_flags |= X509V3_EXT_DYNAMIC; - return X509V3_EXT_add(tmpext); + if (!X509V3_EXT_add(tmpext)) { + free(tmpext); + return 0; + } + return 1; } void |