Check realloc() return value and gracefully handle a failure