]> git.donarmstrong.com Git - samtools.git/commitdiff
fixed a potential memory problem in indexing
authorHeng Li <lh3@live.co.uk>
Tue, 3 Feb 2009 10:43:11 +0000 (10:43 +0000)
committerHeng Li <lh3@live.co.uk>
Tue, 3 Feb 2009 10:43:11 +0000 (10:43 +0000)
bam_index.c
bamtk.c

index 6bc735eeaac4fbbb4318eabd6eb8c07c443465e5..8c2555232772ee6571f0da19593c5b2764b04898 100644 (file)
@@ -158,7 +158,7 @@ bam_index_t *bam_index_core(bamFile fp)
                        fprintf(stderr, "[bam_index_core] the alignment is not sorted. Abort!\n");
                        exit(1);
                }
-               if (b->core.bin < 4681) insert_offset2(&idx->index2[b->core.tid], b, last_off);
+               if (b->core.tid >= 0 && b->core.bin < 4681) insert_offset2(&idx->index2[b->core.tid], b, last_off);
                if (c->bin != last_bin) { // then possibly write the binning index
                        if (save_bin != 0xffffffffu) // save_bin==0xffffffffu only happens to the first record
                                insert_offset(idx->index[save_tid], save_bin, save_off, last_off);
diff --git a/bamtk.c b/bamtk.c
index 631502cfbbd1b5f21b528d1105d9d0a2d73ae54f..9b75ed61b61d12d7c4993c8d298922e7c7ee2975 100644 (file)
--- a/bamtk.c
+++ b/bamtk.c
@@ -3,7 +3,7 @@
 #include "bam.h"
 
 #ifndef PACKAGE_VERSION
-#define PACKAGE_VERSION "0.1.2-3"
+#define PACKAGE_VERSION "0.1.2-4"
 #endif
 
 int bam_taf2baf(int argc, char *argv[]);