Skip to content

Commit ae662c5

Browse files
committed
Fix type mismatch in ccall.c and division by zero in mcall.c
ccall.c: Change `tmpi` from float to int32_t so that bcf_update_info_int32() receives actual integer bits instead of reinterpreting float bits as an int32. mcall.c: Guard the MQ calculation against division by zero when all DP4 counts are zero, consistent with the existing check in test16_core().
1 parent db17826 commit ae662c5

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

ccall.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ static int update_bcf1(call_t *call, bcf1_t *rec, const bcf_p1rst_t *pr, double
141141
int has_I16, is_var;
142142
float fq, r;
143143
anno16_t a;
144-
float tmpf[4], tmpi;
144+
float tmpf[4];
145+
int32_t tmpi;
145146

146147
bcf_get_info_float(call->hdr, rec, "I16", &call->anno16, &call->n16);
147148

mcall.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,8 @@ int mcall(call_t *call, bcf1_t *rec)
16591659
int32_t dp[4]; dp[0] = call->anno16[0]; dp[1] = call->anno16[1]; dp[2] = call->anno16[2]; dp[3] = call->anno16[3];
16601660
bcf_update_info_int32(call->hdr, rec, "DP4", dp, 4);
16611661

1662-
int32_t mq = (call->anno16[8]+call->anno16[10])/(call->anno16[0]+call->anno16[1]+call->anno16[2]+call->anno16[3]);
1662+
int32_t dp4_sum = call->anno16[0]+call->anno16[1]+call->anno16[2]+call->anno16[3];
1663+
int32_t mq = dp4_sum > 0 ? (call->anno16[8]+call->anno16[10])/dp4_sum : 0;
16631664
bcf_update_info_int32(call->hdr, rec, "MQ", &mq, 1);
16641665

16651666
if ( call->output_tags & CALL_FMT_PV4 )

0 commit comments

Comments
 (0)