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

miscutil: Fix dereference invalid iterator #878

Merged

Conversation

ma8ma
Copy link
Collaborator

@ma8ma ma8ma commented Dec 12, 2021

イテレーターを終端チェックする前にデリファレンスしているとcppcheck 2.6.2に指摘されたため修正します。

cppcheckのレポート

src/jdlib/miscutil.cpp:609:26: warning: Either the condition 'it==list_num.end()' is redundant or there is possible dereference of an invalid iterator: it. [derefInvalidIteratorRedundantCheck]
        const int num = *it;
                         ^
src/jdlib/miscutil.cpp:610:39: note: Assuming that condition 'it==list_num.end()' is not redundant
        if( num_from + i != num || it == list_num.end() ){
                                      ^
src/jdlib/miscutil.cpp:609:26: note: Dereference of an invalid iterator
        const int num = *it;
                         ^

関連のpull request: #865

イテレーターを終端チェックする前にデリファレンスしていると
cppcheck 2.6.2に指摘されたため修正します。

cppcheckのレポート
```
src/jdlib/miscutil.cpp:609:26: warning: Either the condition 'it==list_num.end()' is redundant or there is possible dereference of an invalid iterator: it. [derefInvalidIteratorRedundantCheck]
        const int num = *it;
                         ^
src/jdlib/miscutil.cpp:610:39: note: Assuming that condition 'it==list_num.end()' is not redundant
        if( num_from + i != num || it == list_num.end() ){
                                      ^
src/jdlib/miscutil.cpp:609:26: note: Dereference of an invalid iterator
        const int num = *it;
                         ^
```
@ma8ma ma8ma added the bug バグの追跡 label Dec 12, 2021
@ma8ma ma8ma added this to In progress in State of JDim-v0.6.0+ via automation Dec 12, 2021
@ma8ma ma8ma merged commit 1ce5e9b into JDimproved:master Dec 12, 2021
State of JDim-v0.6.0+ automation moved this from In progress to Done Dec 12, 2021
@ma8ma ma8ma deleted the miscutil-fix-derefer-invalid-iterator branch December 12, 2021 12:39
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