yaml2obj might crash on invalid input when unable to parse the YAML.
The reason for the crash is almost the same to one fixed in D59964,
which fixed it for en empty inputs. But as was mentioned in comments,
fix should have been done in yaml::Input instead.
This patch does that and fixes a crash that I faced
(I updated the test case accordingly).