Skip to content

UBSAN: applying non-zero offset 7200 to null pointer in lsf_msvq_ma_enc.c

make clean
make -j CLANG=3
./IVAS_cod -stereo -dtx 48000 32 scripts/testv/stvST32n.wav bit

results in a undef behaviour error in msvq_enc(). The reason is that for the first stage when the DCT-VQ-search optimization is used, cb_stage is NULL, but still is added to in line 558:

            p2 = cb_stage + ( indices[1][c * stages + s] ) * maxn; /* regular ptr init */
            if ( s == 0 && applyDCT_flag != 0 )
            {
                p2 = (const float *) &( st1_syn_vec_ptr[c * FDCNG_VQ_MAX_LEN] ); /*ptr init of stage 1 */
            }

There is no real problem with that as in the next line, the pointer is overwritten again. Still, I would propose to move line 558 into an else branch of the already present if to prevent this from showing up.