Skip to content

Commit

Permalink
Check if VCF POS column could be fully parsed
Browse files Browse the repository at this point in the history
and throw an error if not.

The position too large error report is also fixed so that it
reports the incorrect value instead of an empty string.

Resolves #1570

Co-authored-by: Rob Davies <rmd+git@sanger.ac.uk>
  • Loading branch information
pd3 and daviesrob committed Mar 2, 2023
1 parent c37268c commit 05ef3b7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion vcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3232,9 +3232,13 @@ int vcf_parse(kstring_t *s, const bcf_hdr_t *h, bcf1_t *v)
v->rid = kh_val(d, k).id;
} else if (i == 1) { // POS
overflow = 0;
char *tmp = p;
v->pos = hts_str2uint(p, &p, 63, &overflow);
if (overflow) {
hts_log_error("Position value '%s' is too large", p);
hts_log_error("Position value '%s' is too large", tmp);
goto err;
} else if ( *p ) {
hts_log_error("Could not parse the position '%s'", tmp);
goto err;
} else {
v->pos -= 1;
Expand Down

0 comments on commit 05ef3b7

Please sign in to comment.