Repository navigation
parser: avoid null dereference when fetching first collection token - #350
atharvmantri wants to merge 1 commit into
Conversation
perlpunk
left a comment
There was a problem hiding this comment.
I've seen a similar pull request before and I already commented on that, but somehow it's gone. Did someone delete it?
I don't want to repeat myself.
Have you read my comment in the linked issue #337?
Has your LLM also read it?
There is currently no possibility for the token to be NULL in those cases. If you understand the algorithm, the token at that point was already read, otherwise it wouldn't have entered that function.
If you think there is, give me a reproducer please.
|
Thanks for the careful review. I re-read the discussion on #337 and agree the proposed NULL dereference is not a real bug: when |
|
Closing after review: the issue report was invalid and no reproducer exists. |
Summary
Guard the first
PEEK_TOKEN(parser)result in the four collection-entry parser functions before readingtoken->start_mark.PEEK_TOKENreturnsNULLwhen fetching more tokens fails. Thefirstpath in these functions dereferenced that value without the null check used by the subsequent paths, turning malformed/truncated input or an input/allocation error into a null-pointer crash instead of a parser failure.This fixes the four affected paths:
yaml_parser_parse_block_sequence_entryyaml_parser_parse_block_mapping_keyyaml_parser_parse_flow_sequence_entryyaml_parser_parse_flow_mapping_keyCloses #337.
Testing
git diff --check