Fixed crashing when returning from out of memory