Skip to content

Commit 27b872f

Browse files
committed
Address code review comments.
1 parent 445de25 commit 27b872f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sam.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,8 +3220,10 @@ int sam_format1(const bam_hdr_t *h, const bam1_t *b, kstring_t *str)
32203220
// reference count the structure.
32213221
int sam_write1(htsFile *fp, const sam_hdr_t *hdr, const bam1_t *b)
32223222
{
3223-
const sam_hdr_t *h = hdr;
3224-
if (!h) h = fp->bam_header;
3223+
if (!fp || !b) { errno = EINVAL; return -1; }
3224+
const sam_hdr_t *h = hdr ? hdr : fp->bam_header;
3225+
if (!h) { hts_log_error("No header available for file \"%s\"", fp->fn); return -1; }
3226+
32253227
switch (fp->format.format) {
32263228
case binary_format:
32273229
fp->format.category = sequence_data;

vcf.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3291,8 +3291,6 @@ static int vcf_idx_init(htsFile *fp, bcf_hdr_t *h, int min_shift, const char *fn
32913291
u32_to_le(0, conf+20); // n.skip
32923292
u32_to_le(0, conf+24); // ref name len
32933293
if (hts_idx_set_meta(fp->idx, sizeof(conf)*sizeof(*conf), (uint8_t *)conf, 1) < 0) {
3294-
hts_idx_destroy(fp->idx);
3295-
fp->idx = NULL;
32963294
return -1;
32973295
}
32983296
fp->fnidx = strdup(fnidx);

0 commit comments

Comments
 (0)