Add fix some simple bugs discovered by the fuzzer. Two cases of missing
input validation (we have assertions, but assertion failures are not
user friendly). And one case of jump over variable initialization with
goto.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>