Replace assertions with error return values, thus ensuring an illegal memory access does not occur. PR 33020