Fix segfault when input is empty