input: Add a handling case for memory allocation failure