From 7954e77a1b5117be287f7157cefbcceb2d2d8e5d Mon Sep 17 00:00:00 2001 From: Heng Li Date: Thu, 1 May 2014 11:13:05 -0400 Subject: [PATCH] r741: fixed segfault in rare cases --- bwa.c | 10 ++++++---- main.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bwa.c b/bwa.c index 61656f2..43d8a58 100644 --- a/bwa.c +++ b/bwa.c @@ -107,10 +107,12 @@ uint32_t *bwa_gen_cigar2(const int8_t mat[25], int o_del, int e_del, int o_ins, tmp = rseq[i], rseq[i] = rseq[rlen - 1 - i], rseq[rlen - 1 - i] = tmp; } if (l_query == re - rb && w_ == 0) { // no gap; no need to do DP - // FIXME: due to an issue in mem_reg2aln(), we never come to this block. This does not affect accuracy, but it hurts performance. - cigar = malloc(4); - cigar[0] = l_query<<4 | 0; - *n_cigar = 1; + // UPDATE: we come to this block now... FIXME: due to an issue in mem_reg2aln(), we never come to this block. This does not affect accuracy, but it hurts performance. + if (n_cigar) { + cigar = malloc(4); + cigar[0] = l_query<<4 | 0; + *n_cigar = 1; + } for (i = 0, *score = 0; i < l_query; ++i) *score += mat[rseq[i]*5 + query[i]]; } else { diff --git a/main.c b/main.c index d714f54..94904fa 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,7 @@ #include "utils.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.7.8-r740-dirty" +#define PACKAGE_VERSION "0.7.8-r741-dirty" #endif int bwa_fa2pac(int argc, char *argv[]);