fixed null deref when out of memory