Avoid signed vs. unsigned warnings (which are treated like errors on
[openssl.git] / crypto / asn1 / tasn_new.c
index 3371dd13a7ffc420795bced25c7d6ec1451c232d..6a76a96ba9ceb92c12eebab1696bfa28cce75bb7 100644 (file)
@@ -138,7 +138,12 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int
                if(asn1_cb) {
                        i = asn1_cb(ASN1_OP_NEW_PRE, pval, it);
                        if(!i) goto auxerr;
-                       if(i==2) return 1;
+                       if(i==2) {
+#ifdef CRYPTO_MDEBUG
+                               if(it->sname) CRYPTO_pop_info();
+#endif
+                               return 1;
+                       }
                }
                if(!combine) {
                        *pval = OPENSSL_malloc(it->size);
@@ -150,11 +155,17 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int
                                goto auxerr;
                break;
 
+               case ASN1_ITYPE_NDEF_SEQUENCE:
                case ASN1_ITYPE_SEQUENCE:
                if(asn1_cb) {
                        i = asn1_cb(ASN1_OP_NEW_PRE, pval, it);
                        if(!i) goto auxerr;
-                       if(i==2) return 1;
+                       if(i==2) {
+#ifdef CRYPTO_MDEBUG
+                               if(it->sname) CRYPTO_pop_info();
+#endif
+                               return 1;
+                       }
                }
                if(!combine) {
                        *pval = OPENSSL_malloc(it->size);
@@ -221,6 +232,7 @@ static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
                case ASN1_ITYPE_COMPAT:
                case ASN1_ITYPE_CHOICE:
                case ASN1_ITYPE_SEQUENCE:
+               case ASN1_ITYPE_NDEF_SEQUENCE:
                *pval = NULL;
                break;
        }
@@ -229,7 +241,7 @@ static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
 
 int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
 {
-       const ASN1_ITEM *it = tt->item;
+       const ASN1_ITEM *it = ASN1_ITEM_ptr(tt->item);
        int ret;
        if(tt->flags & ASN1_TFLG_OPTIONAL) {
                asn1_template_clear(pval, tt);
@@ -266,13 +278,13 @@ int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
        return ret;
 }
 
-void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
+static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
 {
        /* If ADB or STACK just NULL the field */
        if(tt->flags & (ASN1_TFLG_ADB_MASK|ASN1_TFLG_SK_MASK)) 
                *pval = NULL;
        else
-               asn1_item_clear(pval, tt->item);
+               asn1_item_clear(pval, ASN1_ITEM_ptr(tt->item));
 }
 
 
@@ -295,7 +307,10 @@ int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
                return 1;
 
                case V_ASN1_BOOLEAN:
-               *(ASN1_BOOLEAN *)pval = it->size;
+               if (it)
+                       *(ASN1_BOOLEAN *)pval = it->size;
+               else
+                       *(ASN1_BOOLEAN *)pval = -1;
                return 1;
 
                case V_ASN1_NULL: