summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/tasn_new.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/tasn_new.c')
-rw-r--r--src/lib/libcrypto/asn1/tasn_new.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c
index e9bbc05e08..7c9bb98974 100644
--- a/src/lib/libcrypto/asn1/tasn_new.c
+++ b/src/lib/libcrypto/asn1/tasn_new.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_new.c,v 1.17 2017/01/29 17:49:22 beck Exp $ */ 1/* $OpenBSD: tasn_new.c,v 1.18 2019/04/01 15:48:04 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -306,10 +306,12 @@ ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
306 ASN1_STRING *str; 306 ASN1_STRING *str;
307 int utype; 307 int utype;
308 308
309 if (it && it->funcs) { 309 if (it != NULL && it->funcs != NULL) {
310 const ASN1_PRIMITIVE_FUNCS *pf = it->funcs; 310 const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
311 if (pf->prim_new) 311
312 return pf->prim_new(pval, it); 312 if (pf->prim_new == NULL)
313 return 0;
314 return pf->prim_new(pval, it);
313 } 315 }
314 316
315 if (!it || (it->itype == ASN1_ITYPE_MSTRING)) 317 if (!it || (it->itype == ASN1_ITYPE_MSTRING))
@@ -355,14 +357,17 @@ static void
355asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) 357asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
356{ 358{
357 int utype; 359 int utype;
358 if (it && it->funcs) { 360
361 if (it != NULL && it->funcs != NULL) {
359 const ASN1_PRIMITIVE_FUNCS *pf = it->funcs; 362 const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
363
360 if (pf->prim_clear) 364 if (pf->prim_clear)
361 pf->prim_clear(pval, it); 365 pf->prim_clear(pval, it);
362 else 366 else
363 *pval = NULL; 367 *pval = NULL;
364 return; 368 return;
365 } 369 }
370
366 if (!it || (it->itype == ASN1_ITYPE_MSTRING)) 371 if (!it || (it->itype == ASN1_ITYPE_MSTRING))
367 utype = V_ASN1_UNDEF; 372 utype = V_ASN1_UNDEF;
368 else 373 else