Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cram/cram_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ int next_cigar_op(uint32_t *cigar, uint32_t ncigar, int *skip, int *spos,
static inline int extend_ref(char **ref, uint32_t (**hist)[5], hts_pos_t pos,
hts_pos_t ref_start, hts_pos_t *ref_end,
hts_pos_t *ref_end_alloc) {
if (*ref_end < pos)
if (*ref_end < pos && pos < *ref_end_alloc)
*ref_end = pos;
if (pos < ref_start)
return -1;
Expand Down Expand Up @@ -1542,6 +1542,9 @@ static inline int extend_ref(char **ref, uint32_t (**hist)[5], hts_pos_t pos,
memset(&(*ref)[old_end], 0, new_end-old_end);
memset(&(*hist)[old_end], 0, (new_end-old_end)*sizeof(**hist));

if (*ref_end < pos)
*ref_end = pos;

return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions header.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ static int sam_hrecs_update_hashes(sam_hrecs_t *hrecs,
return -1; // SN should be present, according to spec.
}

if (len == -1) {
hts_log_error("Header includes @SQ line \"%s\" with no LN: tag",
if (len <= 0) {
hts_log_error("Header includes @SQ line \"%s\" with invalid or no LN: tag",
name);
return -1; // LN should be present, according to spec.
}
Expand Down
Loading