X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sam.c;h=ecdee02dddb98a32d47a59e3154179356acecadf;hb=ceff94a59e7ae16948c2d175c8b165c9889d61df;hp=07524c0213b30bcae3870f8424da38daef43ac49;hpb=d0e30eec1158752010659982342a611fc91ae8e3;p=samtools.git diff --git a/sam.c b/sam.c index 07524c0..ecdee02 100644 --- a/sam.c +++ b/sam.c @@ -12,7 +12,7 @@ bam_header_t *bam_header_dup(const bam_header_t *h0) int i; h = bam_header_init(); *h = *h0; - h->hash = 0; + h->hash = h->dict = h->rg2lib = 0; h->text = (char*)calloc(h->l_text + 1, 1); memcpy(h->text, h0->text, h->l_text); h->target_len = (uint32_t*)calloc(h->n_targets, 4); @@ -55,6 +55,7 @@ samfile_t *samopen(const char *fn, const char *mode, const void *aux) if (aux) { // check if aux is present bam_header_t *textheader = fp->header; fp->header = sam_header_read2((const char*)aux); + if (fp->header == 0) goto open_err_ret; append_header_text(fp->header, textheader->text, textheader->l_text); bam_header_destroy(textheader); } @@ -62,7 +63,6 @@ samfile_t *samopen(const char *fn, const char *mode, const void *aux) fprintf(stderr, "[samopen] no @SQ lines in the header.\n"); } else fprintf(stderr, "[samopen] SAM header is present: %d sequences.\n", fp->header->n_targets); } - sam_header_parse_rg(fp->header); } else if (mode[0] == 'w') { // write fp->header = bam_header_dup((const bam_header_t*)aux); if (mode[1] == 'b') { // binary