From c5617592223e886304eabe087e57a87dc5fadb97 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Fri, 12 Dec 2014 16:56:54 -0500 Subject: [PATCH] r1027: segfault caused by the last commit --- bwa.c | 10 ++++++---- main.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bwa.c b/bwa.c index 6739edd..f9ce6a1 100644 --- a/bwa.c +++ b/bwa.c @@ -370,11 +370,13 @@ int bwa_idx2mem(bwaidx_t *idx) void bwa_print_sam_hdr(const bntseq_t *bns, const char *hdr_line) { int i, n_SQ = 0; - const char *p = hdr_line; extern char *bwa_pg; - while ((p = strstr(p, "@SQ\t")) != 0) { - if (p == hdr_line || *(p-1) == '\n') ++n_SQ; - p += 4; + if (hdr_line) { + const char *p = hdr_line; + while ((p = strstr(p, "@SQ\t")) != 0) { + if (p == hdr_line || *(p-1) == '\n') ++n_SQ; + p += 4; + } } if (n_SQ == 0) { for (i = 0; i < bns->n_seqs; ++i) diff --git a/main.c b/main.c index 2a0118c..887ea28 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,7 @@ #include "utils.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.7.10-r1025-dirty" +#define PACKAGE_VERSION "0.7.10-r1027-dirty" #endif int bwa_fa2pac(int argc, char *argv[]);