embed support for CHOICE type
[oweals/openssl.git] / crypto / asn1 / tasn_new.c
index 294912c188e76209a6da6811558182ad26063cdd..13db8676fc876e7a1085cc3fbc0cf72f5d414897 100644 (file)
@@ -142,9 +142,13 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
                 return 1;
             }
         }
-        *pval = OPENSSL_zalloc(it->size);
-        if (!*pval)
-            goto memerr;
+        if (embed) {
+            memset(*pval, 0, it->size);
+        } else {
+            *pval = OPENSSL_zalloc(it->size);
+            if (!*pval)
+                goto memerr;
+        }
         asn1_set_choice_selector(pval, -1, it);
         if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
             goto auxerr;