Fix reading uninitialized variable right_red in map.c (#349) #362
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.
The struct member right_red is used in several functions, such as rb_node_set_right(). It has been reported by infer and LLVM static analyzer that right_red isn't initialized before being used.
By tracing the node initialization function calls (starting from
map_create_node
), it can be seen thatrb_node_set_right
is the function whereright_red
is attempted to be initialized, but we are indeed performing&1
on an uninitialized value.In this commit, a change to using
calloc
guarantees the struct members will be zeroed out during allocation, which in terms serves as initialization.