do not crash if allocation failed

Change-Id: I2fbc259de52a3c7f2c8c33027d74bb857d44b437