Skip to content

Commit

Permalink
fix for incorrect failure message with invalid reference file and nul…
Browse files Browse the repository at this point in the history
…l check
  • Loading branch information
vasudeva8 committed Dec 21, 2023
1 parent 61b037b commit 2ef4da9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions hts.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,10 +938,15 @@ htsFile *hts_open_format(const char *fn, const char *mode, const htsFormat *fmt)
fmt->format == fastq_format))
fp->format.format = fmt->format;

if (fmt && fmt->specific)
if (hts_opt_apply(fp, fmt->specific) != 0)
if (fmt && fmt->specific) {
if (hts_opt_apply(fp, fmt->specific) != 0) {
if (((hts_opt*)fmt->specific)->opt == CRAM_OPT_REFERENCE) {
//reset error on reference file to avoid incorrect error report
errno = 0;
}
goto error;

}
}
if ( rmme ) free(rmme);
return fp;

Expand Down Expand Up @@ -1595,6 +1600,10 @@ htsFile *hts_hopen(hFILE *hfile, const char *fn, const char *mode)
int hts_close(htsFile *fp)
{
int ret = 0, save;
if (!fp) {
errno = EINVAL;
return -1;
}

switch (fp->format.format) {
case binary_format:
Expand Down

0 comments on commit 2ef4da9

Please sign in to comment.