From f674651974de23bb73b6ef702b460e74fe2348dd Mon Sep 17 00:00:00 2001 From: John Marshall Date: Fri, 29 Oct 2021 10:35:49 +0100 Subject: [PATCH] Fill in cr->rg when writing CRAM v1 As per the other branches of the if-else, set cr->rg. Also rewrite the assert: the previous code produced "brg is unused" warnings when compiled with -DNDEBUG. --- cram/cram_encode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cram/cram_encode.c b/cram/cram_encode.c index 192278f17..468822247 100644 --- a/cram/cram_encode.c +++ b/cram/cram_encode.c @@ -3057,7 +3057,8 @@ static int process_one_read(cram_fd *fd, cram_container *c, cr->rg = brg ? brg->id : -1; } else if (CRAM_MAJOR_VERS(fd->version) == 1) { sam_hrec_rg_t *brg = sam_hrecs_find_rg(fd->header->hrecs, "UNKNOWN"); - assert(brg); + if (!brg) goto block_err; + cr->rg = brg->id; } else { cr->rg = -1; }