Skip to content

utils.h: reject unexpected preceding characters in strToInt()#8490

Open
firewave wants to merge 5 commits intocppcheck-opensource:mainfrom
firewave:test-stoi
Open

utils.h: reject unexpected preceding characters in strToInt()#8490
firewave wants to merge 5 commits intocppcheck-opensource:mainfrom
firewave:test-stoi

Conversation

@firewave
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread lib/utils.h Fixed
Comment thread lib/utils.h Fixed
@firewave firewave marked this pull request as draft April 25, 2026 08:44
@firewave firewave marked this pull request as ready for review April 25, 2026 09:38
Comment thread lib/utils.h
*err = "needs to be positive";
return false;
}
if (str.front() != '+' && isdigit(str.front()) == 0) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have good reasons but personally I would prefer !

Suggested change
if (str.front() != '+' && isdigit(str.front()) == 0) {
if (str.front() != '+' && !isdigit(str.front())) {

== 0 is a bit like misleading somehow..

Copy link
Copy Markdown
Collaborator

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just have a little nit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants