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

This commit is contained in:
Andre Puschmann 2021-04-23 12:02:33 +02:00
parent 92d4e6e746
commit 6e79ae67aa
2 changed files with 3 additions and 3 deletions

View File

@ -147,7 +147,7 @@ void* create_ldpc_dec_c_avx2long_flood(uint8_t bgN, uint8_t bgM, uint16_t ls, fl
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->llrs);
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;
}
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->prod_v2c_epi8);
free(vp->mins_v2c_epi8);

View File

@ -82,7 +82,7 @@ void srsran_polar_chanalloc_rx(const uint8_t* output_decoder,
uint16_t i_o = 0;
uint16_t iPC = 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
if (i_o == PC_set[iPC]) { // skip
iPC = iPC + 1;