Back port rev 1.26 from trunk to MOZILLA_1_4_BRANCH. Fix bug 174885. MOZILLA_1_4_BRANCH
authorwtc%netscape.com
Wed, 28 May 2003 00:15:52 +0000
branchMOZILLA_1_4_BRANCH
changeset 4464 bd945d8d7985a0e9ecfbd3f0a9f41be24685d5e0
parent 4447 413719d5bc7738aa5d052ef6374005b2ebfea5cf (current diff)
parent 4449 41b0bc73dfe72a7e40eebb30ddbc3b2b4b1e5c53 (diff)
child 4465 97b24a8330ecccee7f61909394b7977e89a40854
push idunknown
push userunknown
push dateunknown
bugs174885
Back port rev 1.26 from trunk to MOZILLA_1_4_BRANCH. Fix bug 174885. a=sspitzer.
security/nss/lib/util/secasn1d.c
--- a/security/nss/lib/util/secasn1d.c
+++ b/security/nss/lib/util/secasn1d.c
@@ -929,20 +929,19 @@ sec_asn1d_prepare_for_contents (sec_asn1
 		 * Do the "before" field notification for next in group.
 		 */
 		sec_asn1d_notify_before (state->top, state->dest, state->depth);
 		state = sec_asn1d_init_state_based_on_template (state);
 	    }
 	} else {
 	    /*
 	     * A group of zero; we are done.
-	     * XXX Should we store a NULL here?  Or set state to
-	     * afterGroup and let that code do it?
+	     * Set state to afterGroup and let that code plant the NULL.
 	     */
-	    state->place = afterEndOfContents;
+	    state->place = afterGroup;
 	}
 	return;
     }
 
     switch (state->underlying_kind) {
       case SEC_ASN1_SEQUENCE:
 	/*
 	 * We need to push a child to handle the individual fields.
@@ -1931,17 +1930,18 @@ sec_asn1d_concat_substrings (sec_asn1d_s
 static void
 sec_asn1d_concat_group (sec_asn1d_state *state)
 {
     const void ***placep;
 
     PORT_Assert (state->place == afterGroup);
 
     placep = (const void***)state->dest;
-    if (state->subitems_head != NULL) {
+    PORT_Assert(state->subitems_head == NULL || placep != NULL);
+    if (placep != NULL) {
 	struct subitem *item;
 	const void **group;
 	int count;
 
 	count = 0;
 	item = state->subitems_head;
 	while (item != NULL) {
 	    PORT_Assert (item->next != NULL || item == state->subitems_tail);
@@ -1951,34 +1951,31 @@ sec_asn1d_concat_group (sec_asn1d_state 
 
 	group = (const void**)sec_asn1d_zalloc (state->top->their_pool,
 				  (count + 1) * (sizeof(void *)));
 	if (group == NULL) {
 	    state->top->status = decodeError;
 	    return;
 	}
 
-	PORT_Assert (placep != NULL);
 	*placep = group;
 
 	item = state->subitems_head;
 	while (item != NULL) {
 	    *group++ = item->data;
 	    item = item->next;
 	}
 	*group = NULL;
 
 	/*
 	 * Because we use arenas and have a mark set, we later free
 	 * everything we have allocated, so this does *not* present
 	 * a memory leak (it is just temporarily left dangling).
 	 */
 	state->subitems_head = state->subitems_tail = NULL;
-    } else if (placep != NULL) {
-	*placep = NULL;
     }
 
     state->place = afterEndOfContents;
 }
 
 
 /*
  * For those states that push a child to handle a subtemplate,