ASN1: Fix NULL pointer dereference on stack allocation failure.
authorKp <kp@valhallalegends.com>
Sat, 31 May 2008 04:31:07 +0000 (23:31 -0500)
committerKp <kp@valhallalegends.com>
Mon, 1 Sep 2008 19:52:21 +0000 (14:52 -0500)
If the second silc_stack_alloc fails, then asn1->stack2 is NULL.  Thus,
when silc_asn1_init calls silc_stack_free(asn1->stack2), it is
equivalent to silc_stack_free(NULL).  However, silc_stack_free does not
check for a NULL pointer.  Fix silc_asn1_init to free asn1->stack1, as
was intended.

lib/silcasn1/silcasn1.c

index 5965228..2e43b49 100644 (file)
@@ -53,7 +53,7 @@ SilcBool silc_asn1_init(SilcAsn1 asn1)
 
   asn1->stack2 = silc_stack_alloc(768);
   if (!asn1->stack2) {
-    silc_stack_free(asn1->stack2);
+    silc_stack_free(asn1->stack1);
     return FALSE;
   }