Skip to content

Commit 19c1894

Browse files
jenniferliddlejmarshall
authored andcommitted
Fix bugs in bam_aux_update_str()
s/m_data/data/ and remove casts that were suppressing a warning that would have diagnosed this mistake. Resample bam_get_aux(), which may also be changed by the realloc().
1 parent 0ca17a0 commit 19c1894

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

sam.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,17 +1304,16 @@ int bam_aux_update_str(bam1_t *b, const char tag[2], int len, const char *data)
13041304
bam_aux_del(b,s);
13051305
s -= 2;
13061306
int l_aux = bam_get_l_aux(b);
1307-
uint8_t *aux = bam_get_aux(b);
13081307

13091308
b->l_data += 3 + len;
13101309
if (b->m_data < b->l_data) {
1311-
ptrdiff_t s_offset = (ptrdiff_t) (s - b->m_data);
1310+
ptrdiff_t s_offset = s - b->data;
13121311
b->m_data = b->l_data;
13131312
kroundup32(b->m_data);
13141313
b->data = (uint8_t*)realloc(b->data, b->m_data);
1315-
s = (uint8_t *) (b->m_data + s_offset);
1314+
s = b->data + s_offset;
13161315
}
1317-
memmove(s+3+len, s, l_aux - (s - aux));
1316+
memmove(s+3+len, s, l_aux - (s - bam_get_aux(b)));
13181317
s[0] = tag[0];
13191318
s[1] = tag[1];
13201319
s[2] = type;

0 commit comments

Comments
 (0)