fixed wrong return if out of memory