Created SILC Crypto Toolkit git repository.
[crypto.git] / lib / silcasn1 / silcasn1.c
index b80a1c0926b52cc108590682a54087b69026c780..3e9426aadfb8180cf8f73dd7d44fe02771692563 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2003 - 2007 Pekka Riikonen
+  Copyright (C) 2003 - 2008 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
 
 */
 
-#include "silc.h"
+#include "silccrypto.h"
 #include "silcasn1.h"
 #include "silcber.h"
 
@@ -84,8 +84,15 @@ SilcBool silc_asn1_init(SilcAsn1 asn1, SilcStack stack)
 
 void silc_asn1_uninit(SilcAsn1 asn1)
 {
+  SilcStack stack1 = asn1->stack1;
+
+  if (asn1->switched) {
+    stack1 = asn1->stack2;
+    asn1->stack2 = asn1->stack1;
+  }
+
   silc_stack_free(asn1->stack2);
-  silc_stack_free(asn1->stack1);
+  silc_stack_free(stack1);
 }
 
 #if defined(SILC_DEBUG)