Skip to content

Commit

Permalink
BUGFIX header.c sam_hdr_remove_line_pos()
Browse files Browse the repository at this point in the history
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);
*/
  • Loading branch information
Julian Regalado committed Oct 23, 2024
1 parent 3c90481 commit 85dfae0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion header.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 85dfae0

Please sign in to comment.