ldpc/polar: add casts to avoid possible variable overflow before assignment

master
Andre Puschmann 4 years ago
parent 92d4e6e746
commit 6e79ae67aa

@ -147,7 +147,7 @@ void* create_ldpc_dec_c_avx2long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, fl
return NULL; return NULL;
} }
if ((vp->check_to_var = srsran_vec_malloc((hrr + 1) * bgM * n_subnodes * sizeof(__m256i))) == NULL) { if ((vp->check_to_var = srsran_vec_malloc((long)(hrr + 1) * bgM * n_subnodes * sizeof(__m256i))) == NULL) {
free(vp->soft_bits); free(vp->soft_bits);
free(vp->llrs); free(vp->llrs);
free(vp); free(vp);
@ -205,7 +205,7 @@ void* create_ldpc_dec_c_avx2long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, fl
return NULL; return NULL;
} }
if ((vp->rotated_v2c = srsran_vec_malloc((hrr + 1) * n_subnodes * sizeof(__m256i))) == NULL) { if ((vp->rotated_v2c = srsran_vec_malloc((long)(hrr + 1) * n_subnodes * sizeof(__m256i))) == NULL) {
free(vp->min_ix_epi8); free(vp->min_ix_epi8);
free(vp->prod_v2c_epi8); free(vp->prod_v2c_epi8);
free(vp->mins_v2c_epi8); free(vp->mins_v2c_epi8);

@ -82,7 +82,7 @@ void srsran_polar_chanalloc_rx(const uint8_t* output_decoder,
uint16_t i_o = 0; uint16_t i_o = 0;
uint16_t iPC = 0; uint16_t iPC = 0;
uint16_t iK = 0; uint16_t iK = 0;
for (uint16_t iKPC = 0; iKPC < K + nPC; iKPC++) { for (uint16_t iKPC = 0; iKPC < K + (uint16_t)nPC; iKPC++) {
i_o = K_set[iKPC]; // includes parity bits i_o = K_set[iKPC]; // includes parity bits
if (i_o == PC_set[iPC]) { // skip if (i_o == PC_set[iPC]) { // skip
iPC = iPC + 1; iPC = iPC + 1;

Loading…
Cancel
Save