From 47c65ef17d8949832a0c79c552118b31154bc2ad Mon Sep 17 00:00:00 2001 From: Heng Li Date: Tue, 3 Feb 2009 10:43:11 +0000 Subject: [PATCH] fixed a potential memory problem in indexing --- bam_index.c | 2 +- bamtk.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bam_index.c b/bam_index.c index 6bc735e..8c25552 100644 --- a/bam_index.c +++ b/bam_index.c @@ -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 631502c..9b75ed6 100644 --- 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[]); -- 2.39.5