command_check_batch(): fix memory leak, catch memory allocation errors