From 58a05bef0e3714d8aeca24504e061466b23dab8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Rognes?= Date: Fri, 26 Apr 2024 15:02:21 +0200 Subject: [PATCH] Fix segfault with blast6out and output_no_hits options --- src/results.cc | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/results.cc b/src/results.cc index ae176506..276c19be 100644 --- a/src/results.cc +++ b/src/results.cc @@ -194,29 +194,31 @@ void results_show_blast6out_one(FILE * fp, but only 12 when there is a hit. Fixed in VSEARCH. */ - if (not hp) + if (hp) + { + // if 'hp->strand' then 'minus strand' else 'plus strand' + const int qstart = hp->strand ? qseqlen : 1; + const int qend = hp->strand ? 1 : qseqlen; + + fprintf(fp, + "%s\t%s\t%.1f\t%d\t%d\t%d\t%d\t%d\t%d\t%" PRIu64 "\t%d\t%d\n", + query_head, + db_getheader(hp->target), + hp->id, + hp->internal_alignmentlength, + hp->mismatches, + hp->internal_gaps, + qstart, + qend, + 1, + db_getsequencelen(hp->target), + -1, + 0); + } + else { fprintf(fp, "%s\t*\t0.0\t0\t0\t0\t0\t0\t0\t0\t-1\t0\n", query_head); } - - // if 'hp->strand' then 'minus strand' else 'plus strand' - const int qstart = hp->strand ? qseqlen : 1; - const int qend = hp->strand ? 1 : qseqlen; - - fprintf(fp, - "%s\t%s\t%.1f\t%d\t%d\t%d\t%d\t%d\t%d\t%" PRIu64 "\t%d\t%d\n", - query_head, - db_getheader(hp->target), - hp->id, - hp->internal_alignmentlength, - hp->mismatches, - hp->internal_gaps, - qstart, - qend, - 1, - db_getsequencelen(hp->target), - -1, - 0); } void results_show_uc_one(FILE * fp,