Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix parsing nested arrays #1189

Merged
merged 1 commit into from May 7, 2023
Merged

fix: fix parsing nested arrays #1189

merged 1 commit into from May 7, 2023

Conversation

andydunstall
Copy link
Contributor

Fixes a bug parsing nested arrays in client mode.

When parse_stack_.emplace_back(len, cached_expr_) is called before creating the new array, the root array would be added to parse_stack_ twice and the leaf array would never be added. That means when a stack was popped, cached_expr_ would end up pointing to the wrong array.

Such as the array [[['foo'],['bar']],['car']] ("*2\r\n*2\r\n*1\r\n$3\r\nfoo\r\n*1\r\n$3\r\nbar\r\n*1\r\n$3\r\ncar\r\n") would have been parsed as [[['foo']],['bar'],['car']], since after foo was parsed such that the nested array was at capacity, popping the stack would end up pointing cached_expr_ to the root array instead of the first nested array.

Signed-off-by: Andrew Dunstall <andydunstall@hotmail.co.uk>
@romange romange requested a review from dranikpg May 7, 2023 08:51
Copy link
Contributor

@dranikpg dranikpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch 👍🏻

@dranikpg dranikpg merged commit 79da3e6 into dragonflydb:main May 7, 2023
6 checks passed
romange pushed a commit that referenced this pull request Jun 1, 2023
Signed-off-by: Andrew Dunstall <andydunstall@hotmail.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants