Skip to content

UBSAN: member access within null pointer of type 'struct ivas_spar_dec_lib_t' in MASA decoder setup

When running a testcase from selftest like so:

./IVAS_cod -MASA 2 scripts/testv/stv1MASA2TC48c.met 96000 48 scripts/testv/stv1MASA2TC48c.wav bit
./IVAS_dec mono 48 bit out.wav

In ivas_dirac_config.c:140, ( (Decoder_Struct *) st_ivas )->hSpar is NULL, but a member access happens which is undefined behaviour. I don't know why this is not reported by the address sanitizer, maybe because it is not strictly dereferencing a null pointer. One possible easy fix is to move the line up into the if branch in line 131++.

This is reported by UBSAN when compiling with make CLANG=3. Just as a note: there are also other errors reported for the same command line, this one can easily also be found if running the commands and setting a breakpoint at the given line and inspecting the variable values.