From 8fb7cbacab48e90ba7e445569ff7a287ddc413fe Mon Sep 17 00:00:00 2001 From: Xiuwen Zheng Date: Thu, 2 Nov 2017 17:30:46 -0700 Subject: [PATCH] fix 'LENGTH or similar applied to NULL object' --- DESCRIPTION | 4 ++-- NEWS | 8 ++++++-- src/ConvToGDS.cpp | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9e3c3c7..93c105c 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,8 +2,8 @@ Package: SNPRelate Type: Package Title: Parallel Computing Toolset for Relatedness and Principal Component Analysis of SNP Data -Version: 1.12.0 -Date: 2017-10-31 +Version: 1.12.1 +Date: 2017-11-02 Depends: R (>= 2.15), gdsfmt (>= 1.8.3) LinkingTo: gdsfmt Suggests: parallel, RUnit, knitr, MASS, BiocGenerics diff --git a/NEWS b/NEWS index 9ab0b2c..2bb38bd 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,11 @@ -CHANGES IN VERSION 1.11.0-1.11.2 +CHANGES IN VERSION 1.12.1 ------------------------- - o the version number was bumped for the Bioconductor release version 3.5 + o fix an issue in C codes 'LENGTH or similar applied to NULL object' + + +CHANGES IN VERSION 1.12.0 +------------------------- o new arguments 'with.sample.id' and 'with.snp.id' in `snpgdsSNPRateFreq()` diff --git a/src/ConvToGDS.cpp b/src/ConvToGDS.cpp index 45d31c5..ed3acfe 100755 --- a/src/ConvToGDS.cpp +++ b/src/ConvToGDS.cpp @@ -723,7 +723,8 @@ COREARRAY_DLL_EXPORT SEXP gnrParseVCF4(SEXP vcf_fn, SEXP gds_root, // chr prefix vector ChrPref; - for (int i=0; i < XLENGTH(ChrPrefix); i++) + const int n_chr_prefix = !Rf_isNull(ChrPrefix) ? XLENGTH(ChrPrefix) : 0; + for (int i=0; i < n_chr_prefix; i++) ChrPref.push_back(CHAR(STRING_ELT(ChrPrefix, i))); @@ -752,7 +753,7 @@ COREARRAY_DLL_EXPORT SEXP gnrParseVCF4(SEXP vcf_fn, SEXP gds_root, string sCHROM, sPOS, sID, sREF, sALT; vector AlleleList; - R_xlen_t AlleleCount = XLENGTH(RefAllele); + R_xlen_t AlleleCount = !Rf_isNull(RefAllele) ? XLENGTH(RefAllele) : 0; while (!RL.IfEnd()) {