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

The atoi exception was not caught #766

Closed
2 tasks done
Ranxy opened this issue Aug 3, 2022 · 1 comment · Fixed by #767
Closed
2 tasks done

The atoi exception was not caught #766

Ranxy opened this issue Aug 3, 2022 · 1 comment · Fixed by #767
Labels
enhancement type enhancement

Comments

@Ranxy
Copy link
Contributor

Ranxy commented Aug 3, 2022

Search before asking

  • I had searched in the issues and found no similar issues.

Motivation

There is some code in the project as follows

try {
        slot_ = atoi(args[2].c_str());
        dst_node_id_ = args[3];
      } catch (std::exception &e) {
        return Status(Status::RedisParseErr, errValueNotInterger);
      }

However atoi does not throw exceptions, so perhaps we should use std::stoi to replace these.

Solution

Replace atoi to std::stoi

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@Ranxy Ranxy added the enhancement type enhancement label Aug 3, 2022
@git-hulk
Copy link
Member

git-hulk commented Aug 3, 2022

Good catch, I think we can use Util::OctalStringToNum to replace the atoi which also can check the min/max boundary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement type enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants