diff libtomcrypt/src/pk/asn1/der/sequence/der_sequence_free.c @ 1471:6dba84798cd5

Update to libtomcrypt 1.18.1, merged with Dropbear changes
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 21:44:05 +0800
parents f849a5ca2efc
children
line wrap: on
line diff
--- a/libtomcrypt/src/pk/asn1/der/sequence/der_sequence_free.c	Thu Feb 08 23:11:40 2018 +0800
+++ b/libtomcrypt/src/pk/asn1/der/sequence/der_sequence_free.c	Fri Feb 09 21:44:05 2018 +0800
@@ -5,8 +5,6 @@
  *
  * The library is free for all purposes without any express
  * guarantee it works.
- *
- * Tom St Denis, [email protected], http://libtom.org
  */
 #include "tomcrypt.h"
 
@@ -20,11 +18,13 @@
 /**
   Free memory allocated by der_decode_sequence_flexi()
   @param in     The list to free
-*/  
+*/
 void der_sequence_free(ltc_asn1_list *in)
 {
    ltc_asn1_list *l;
-   
+
+   if (!in) return;
+
    /* walk to the start of the chain */
    while (in->prev != NULL || in->parent != NULL) {
       if (in->parent != NULL) {
@@ -33,7 +33,7 @@
           in = in->prev;
       }
    }
-   
+
    /* now walk the list and free stuff */
    while (in != NULL) {
       /* is there a child? */
@@ -42,24 +42,22 @@
          in->child->parent = NULL;
          der_sequence_free(in->child);
       }
-      
-      switch (in->type) { 
-         case LTC_ASN1_SET:
-         case LTC_ASN1_SETOF:
-         case LTC_ASN1_SEQUENCE: break;
+
+      switch (in->type) {
+         case LTC_ASN1_SETOF: break;
          case LTC_ASN1_INTEGER : if (in->data != NULL) { mp_clear(in->data); } break;
          default               : if (in->data != NULL) { XFREE(in->data);    }
       }
-      
+
       /* move to next and free current */
       l = in->next;
-      free(in);
+      XFREE(in);
       in = l;
-   }     
+   }
 }
 
 #endif
 
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref:         $Format:%D$ */
+/* git commit:  $Format:%H$ */
+/* commit time: $Format:%ai$ */