]> git.donarmstrong.com Git - samtools.git/commitdiff
Added sam_header_line_free call for sam_header_parse2
authorPetr Danecek <pd3@sanger.ac.uk>
Sat, 24 Oct 2009 13:43:25 +0000 (13:43 +0000)
committerPetr Danecek <pd3@sanger.ac.uk>
Sat, 24 Oct 2009 13:43:25 +0000 (13:43 +0000)
sam_header.c

index 718bd1d8a4a2175fcbe3dc245aee00a868364d3c..f97472db472c31f67d18ccf17224f908dd82db74 100644 (file)
@@ -426,23 +426,27 @@ void print_header_line(FILE *fp, HeaderLine *hline)
 }
 
 
+void sam_header_line_free(HeaderLine *hline)
+{
+    list_t *tags = hline->tags;
+    while (tags)
+    {
+        HeaderTag *tag = tags->data;
+        free(tag->value);
+        free(tag);
+        tags = tags->next;
+    }
+    list_free(hline->tags);
+    free(hline);
+}
+
 void sam_header_free(void *_header)
 {
        HeaderDict *header = (HeaderDict*)_header;
     list_t *hlines = header;
     while (hlines)
     {
-        HeaderLine *hline = hlines->data;
-        list_t *tags = hline->tags;
-        while (tags)
-        {
-            HeaderTag *tag = tags->data;
-            free(tag->value);
-            free(tag);
-            tags = tags->next;
-        }
-        list_free(hline->tags);
-        free(hline);
+        sam_header_line_free(hlines->data);
         hlines = hlines->next;
     }
     list_free(header);
@@ -532,7 +536,9 @@ void *sam_header_parse2(const char *headerText)
             hlines = list_append(hlines, hline);
         else
         {
+            sam_header_line_free(hline);
             sam_header_free(hlines);
+            if ( buf ) free(buf);
             return NULL;
         }
     }