From cf0e7568e155f1d8e194938ed3b97fb544bc3a25 Mon Sep 17 00:00:00 2001 From: Julian Regalado Date: Wed, 23 Oct 2024 11:11:51 +0200 Subject: [PATCH] BUGFIX header.c sam_hdr_remove_line_pos() Parameter check on argument 'position' was not accounting for 0 based indeces as per header description: /* sam.h /// Remove nth line of a given type from a header /*! * @param type Type of the searched line. Eg. "SQ" * @param position Index in lines of this type (zero-based). E.g. 3 * @return 0 on success, -1 on error * * Remove a line from the header by specifying the position in the type * group, i.e. 3rd @SQ line. */ HTSLIB_EXPORT int sam_hdr_remove_line_pos(sam_hdr_t *h, const char *type, int position); */ --- header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/header.c b/header.c index 7f62074f0..d83b2b866 100644 --- a/header.c +++ b/header.c @@ -1450,7 +1450,7 @@ int sam_hdr_remove_line_id(sam_hdr_t *bh, const char *type, const char *ID_key, int sam_hdr_remove_line_pos(sam_hdr_t *bh, const char *type, int position) { sam_hrecs_t *hrecs; - if (!bh || !type || position <= 0) + if (!bh || !type || position < 0) return -1; if (!(hrecs = bh->hrecs)) {