UBSAN: applying non-zero offset 240 to null pointer in ivas_dirac_dec
When running
./IVAS_cod -MASA 2 scripts/testv/stv1MASA2TC48c.met 96000 48 scripts/testv/stv1MASA2TC48c.wav bit
./IVAS_dec mono 48 bit out.wav
UBSAN reports (among other errors):
lib_dec/ivas_dirac_dec.c:2377:52: runtime error: applying non-zero offset 240 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior lib_dec/ivas_dirac_dec.c:2377:52 in
If I understand correctly, DirAC_mem.onset_filter is NULL when hDirAC->proto_signal_decorr_on == 0 is true and there are also checks in place all around the codec so that it is never accessed in that case (ideally to be verified). So, the problematic line
onset_filter_subframe = DirAC_mem.onset_filter + hDirAC->num_freq_bands;
should not be an actual problem. Still, in case of onset_filter being a NULL pointer, I guess it is logical to also have onset_filter_subframe be a NULL pointer. That way, if it is under some circumstances still accessed somewhere, we at least should get an address sanitizer warning or a crash.
My proposal would thus be to change the line to
onset_filter_subframe = ( DirAC_mem.onset_filter == NULL ) ? NULL : DirAC_mem.onset_filter + hDirAC->num_freq_bands;
That would need review and verification by the DirAC experts.