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 authored and jkbonfield committed Oct 29, 2024
1 parent d43c5f6 commit cf0e756
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 cf0e756

Please sign in to comment.