X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bam_index.c;h=d6b94e2413e1dab2d2dc4ce2c91e471854ddd35a;hb=607d7a0ab79152be4153fa09861cfa889488f2c7;hp=9610a2656031657b796abc68bf32c1b6f1564745;hpb=cb5f44947629a68d16a48d32eef6e42a66e482fe;p=samtools.git diff --git a/bam_index.c b/bam_index.c index 9610a26..d6b94e2 100644 --- a/bam_index.c +++ b/bam_index.c @@ -159,9 +159,14 @@ bam_index_t *bam_index_core(bamFile fp) bam1_core_t *c; uint64_t save_off, last_off, n_mapped, n_unmapped, off_beg, off_end, n_no_coor; + h = bam_header_read(fp); + if(h == 0) { + fprintf(stderr, "[bam_index_core] Invalid BAM header."); + return NULL; + } + idx = (bam_index_t*)calloc(1, sizeof(bam_index_t)); b = (bam1_t*)calloc(1, sizeof(bam1_t)); - h = bam_header_read(fp); c = &b->core; idx->n = h->n_targets;