From 2dbbcf655e077bb3d69de0a0ba9f8bb6db99b704 Mon Sep 17 00:00:00 2001 From: John Marshall Date: Mon, 27 Sep 2021 20:47:22 +0100 Subject: [PATCH] Fix hts_idx_get_n_no_coor() out-of-bounds memory access For CRAI-indexed CRAM files idx actually points to an hts_cram_idx_t, which has no n_no_coor field. Return an appropriate "not available" value instead. --- hts.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hts.c b/hts.c index e31615822..e2d6ba44d 100644 --- a/hts.c +++ b/hts.c @@ -2789,6 +2789,7 @@ int hts_idx_get_stat(const hts_idx_t* idx, int tid, uint64_t* mapped, uint64_t* uint64_t hts_idx_get_n_no_coor(const hts_idx_t* idx) { + if (idx->fmt == HTS_FMT_CRAI) return 0; return idx->n_no_coor; }