Skip to content

Commit

Permalink
Prevent crash when only FASTA entry has no sequence.
Browse files Browse the repository at this point in the history
Eg the minimal file of:

    >foo

Credit to OSS-Fuzz
Fixes oss-fuzz 51378
  • Loading branch information
jkbonfield committed Sep 15, 2022
1 parent 6366029 commit a1dec95
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -3853,7 +3853,6 @@ static int fastq_parse1(htsFile *fp, bam1_t *b) {
}

// Name

if (*x->name.s != x->nprefix)
return -2;

Expand Down Expand Up @@ -3893,8 +3892,8 @@ static int fastq_parse1(htsFile *fp, bam1_t *b) {
if ((ret = hts_getline(fp, KS_SEP_LINE, &fp->line)) < 0)
if (fp->format.format == fastq_format || ret < -1)
return -2;
if (*fp->line.s == (fp->format.format == fastq_format ? '+' : '>')
|| ret == -1)
if (ret == -1 ||
*fp->line.s == (fp->format.format == fastq_format ? '+' : '>'))
break;
if (kputsn(fp->line.s, fp->line.l, &x->seq) < 0)
return -2;
Expand Down

0 comments on commit a1dec95

Please sign in to comment.