sds.c: Fix potential overflow in sdsll2str.#8910
Merged
oranagra merged 1 commit intoredis:unstablefrom Aug 8, 2021
Merged
Conversation
Contributor
Author
oranagra
approved these changes
Aug 5, 2021
Member
There was a problem hiding this comment.
I'm on the fence here.
on one hand, having code that relies on undefined behavior is very dangerous.
even if the compiler does the right thing usually, the optimizer can make some assumption and mess up.
on the other hand, i'm quite certain that all compilers handle this right, and such "fixes" make the code harder to read.
I do see that Antirez added similar fix in the past (c951c3e), so i suppose he would have merged this.
@yossigo WDYT?
JackieXie168
pushed a commit
to JackieXie168/redis
that referenced
this pull request
Sep 8, 2021
Fixes an undefined behavior, same way as our `ll2string` does.
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.
i saw a ref issue: #4110
I did some tests, the test code:
output: The output is fine
But there will be a warning when compiling. So i think better have this fixed?
Maybe. I realize it's not very needed or necessary... Feel free to close it and the ref issue