-
Notifications
You must be signed in to change notification settings - Fork 468
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(rdb): incorrect type conversion during RDB loads the int8 encoding #2547
fix(rdb): incorrect type conversion during RDB loads the int8 encoding #2547
Conversation
@@ -157,7 +157,7 @@ StatusOr<std::string> RDB::loadEncodedString() { | |||
unsigned char buf[4] = {0}; | |||
if (len == RDBEncInt8) { | |||
auto next = GET_OR_RET(stream_->ReadByte()); | |||
return std::to_string(static_cast<int>(next)); | |||
return std::to_string(static_cast<int8_t>(next)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why int
if the length is 8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try uint8_t
? However, I'm not sure that it's the right type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be correct to use int8_t here since the encoding is int8. Cast it to int
will drop the sign bit.
@fstd2 It would be great if you could add a Go test case to prevent breaking in the future. |
I'm a beginner, don't know how to do.. |
@fstd2 No worry, I will do this later if you don't know how to. Thank you! |
Quality Gate failedFailed conditions |
Resolve #2546