From a8e16d214ead0305e61b13745e838ccdd93dff8d Mon Sep 17 00:00:00 2001 From: Shawn Sullivan Date: Wed, 19 Dec 2018 11:43:36 -0800 Subject: [PATCH 1/2] Fix segfault on Ubuntu caused by passing NULL to strtok --- src/bam_filt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bam_filt.c b/src/bam_filt.c index 3a2dc0a..c21f5e6 100644 --- a/src/bam_filt.c +++ b/src/bam_filt.c @@ -88,6 +88,10 @@ int parse_target_list(bam_hdr_t *header){ if(header->n_targets == 0) { fprintf(stderr, "WARNING : no sequences in bam header : in : %s\n", __func__); } + + // strtok will cause a seg fault if you giv it a NULL at least for Unbuntu + if(bamfilt_global_opts.exclude_str == NULL) return 0; + char * pch = strtok (bamfilt_global_opts.exclude_str,","); uint32_t nseq = 0; while (pch != NULL) From b374234e4edab940b40f95f5944c9bb550518b8b Mon Sep 17 00:00:00 2001 From: Shawn Sullivan Date: Wed, 19 Dec 2018 11:45:56 -0800 Subject: [PATCH 2/2] Fix whitespace --- src/bam_filt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bam_filt.c b/src/bam_filt.c index c21f5e6..08a6414 100644 --- a/src/bam_filt.c +++ b/src/bam_filt.c @@ -89,8 +89,8 @@ int parse_target_list(bam_hdr_t *header){ fprintf(stderr, "WARNING : no sequences in bam header : in : %s\n", __func__); } - // strtok will cause a seg fault if you giv it a NULL at least for Unbuntu - if(bamfilt_global_opts.exclude_str == NULL) return 0; + // strtok will cause a seg fault if you giv it a NULL at least for Unbuntu + if(bamfilt_global_opts.exclude_str == NULL) return 0; char * pch = strtok (bamfilt_global_opts.exclude_str,","); uint32_t nseq = 0;