fix segfault on malformed input