strcat(strcpy(fnidx, fn), ".bai");
fprintf(stderr, "[bam_index_load] attempting to download the remote index file.\n");
download_from_remote(fnidx);
+ free(fnidx);
idx = bam_index_load_local(fn);
}
if (idx == 0) fprintf(stderr, "[bam_index_load] fail to load BAM index.\n");
if (fpidx == 0) {
fprintf(stderr, "[bam_index_build2] fail to create the index file.\n");
free(fnidx);
+ bam_index_destroy(idx);
return -1;
}
bam_index_save(idx, fpidx);
if (fpidx == 0) {
fprintf(stderr, "[bcf_idx_build2] fail to create the index file.\n");
free(fnidx);
+ bcf_idx_destroy(idx);
return -1;
}
bcf_idx_save(idx, fpidx);
memset(&smpl, 0, sizeof(kstring_t));
while (ks_getuntil(v->ks, '\n', &v->line, &dret) >= 0) {
if (v->line.l < 2) continue;
- if (v->line.s[0] != '#') return 0; // no sample line
+ if (v->line.s[0] != '#') {
+ free(meta.s);
+ free(smpl.s);
+ free(h);
+ return 0; // no sample line
+ }
if (v->line.s[0] == '#' && v->line.s[1] == '#') {
kputsn(v->line.s, v->line.l, &meta); kputc('\n', &meta);
} else if (v->line.s[0] == '#') {
while (*to && *to=='\t') to++;
if ( to-from != 1 ) {
debug("[sam_header_line_parse] multiple tabs on line [%s] (%d)\n", headerLine,(int)(to-from));
+ free(hline);
return 0;
}
from = to;