Fixes segfaults upon allocation failure. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>