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

Dom: Fix accessing first character for std::string #305

Merged
merged 1 commit into from May 24, 2020

Conversation

ma8ma
Copy link
Collaborator

@ma8ma ma8ma commented May 24, 2020

std::stringの変数について冗長または範囲外なアクセスの可能性をcppcheckに警告されたため条件文を整理して修正します。

cppcheckのレポート

src/xml/dom.cpp:133:41: warning: Either the condition 'open_tag.empty()' is redundant or expression 'open_tag[0]' cause access out of bounds. [containerOutOfBounds]
            bool is_alpha = ( ( open_tag[0] >= 'A' && open_tag[0] <= 'Z' ) || ( open_tag[0] >= 'a' && open_tag[0] <= 'z' ) );
                                        ^
src/xml/dom.cpp:137:31: note: Assuming that condition 'open_tag.empty()' is not redundant
            if( open_tag.empty() || ! is_alpha ) continue;
                              ^
src/xml/dom.cpp:133:41: note: Access out of bounds
            bool is_alpha = ( ( open_tag[0] >= 'A' && open_tag[0] <= 'Z' ) || ( open_tag[0] >= 'a' && open_tag[0] <= 'z' ) );
                                        ^

std::stringの変数について冗長または範囲外なアクセスの可能性を
cppcheckに警告されたため条件文を整理して修正します。

cppcheckのレポート
```
src/xml/dom.cpp:133:41: warning: Either the condition 'open_tag.empty()' is redundant or expression 'open_tag[0]' cause access out of bounds. [containerOutOfBounds]
            bool is_alpha = ( ( open_tag[0] >= 'A' && open_tag[0] <= 'Z' ) || ( open_tag[0] >= 'a' && open_tag[0] <= 'z' ) );
                                        ^
src/xml/dom.cpp:137:31: note: Assuming that condition 'open_tag.empty()' is not redundant
            if( open_tag.empty() || ! is_alpha ) continue;
                              ^
src/xml/dom.cpp:133:41: note: Access out of bounds
            bool is_alpha = ( ( open_tag[0] >= 'A' && open_tag[0] <= 'Z' ) || ( open_tag[0] >= 'a' && open_tag[0] <= 'z' ) );
                                        ^
```
@ma8ma ma8ma added the bug バグの追跡 label May 24, 2020
@ma8ma ma8ma merged commit 1051f5c into JDimproved:master May 24, 2020
@ma8ma ma8ma added this to Done in State of JDim-v0.3.0+ via automation May 24, 2020
@ma8ma ma8ma deleted the dom-fix-string-access branch May 24, 2020 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug バグの追跡
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant