fix: guard against divide-by-zero in unmarshalVector when Dimensions is 0#771
Closed
mykaul wants to merge 1 commit intoscylladb:masterfrom
Closed
fix: guard against divide-by-zero in unmarshalVector when Dimensions is 0#771mykaul wants to merge 1 commit intoscylladb:masterfrom
mykaul wants to merge 1 commit intoscylladb:masterfrom
Conversation
…is 0 unmarshalVector computes elemSize = len(data) / info.Dimensions without checking for zero dimensions, causing a panic on the generic reflect-based path. Add an early guard that returns an empty slice for empty data, or a descriptive error when non-empty data is paired with 0 dimensions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
unmarshalVectorcomputeselemSize = len(data) / info.Dimensionswithout checking for zero dimensions, causing a runtime panic on the generic reflect-based pathdata == nilcheck: returns an empty slice for empty data with 0 dimensions, or a descriptive error when non-empty data is paired with 0 dimensionsContext
This is a pre-existing bug in the generic
unmarshalVectorpath, not introduced by any recent PR. It was identified during review of PR #770 (vector marshal optimization) but exists independently on master.The fast-path code in #770 is not affected since its type-specialized functions handle the dimension count via
len(data) / elemByteSize(byte size is always > 0 for float32/float64/int32/int64).