fix: NULL deref in qideal test

NOTE: adaptation of 071e6adf671c14d7003accadcce5271a90cde970 to SW