Bug 411323 - kdevelop-5.4.1/plugins/clang/duchain/unknowndeclarationproblem.cpp:144:44: warning: Possible dereference of an invalid iterator: x
Summary: kdevelop-5.4.1/plugins/clang/duchain/unknowndeclarationproblem.cpp:144:44: wa...
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: general (show other bugs)
Version: 5.4.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-26 16:56 UTC by dcb314
Modified: 2019-08-26 20:47 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dcb314 2019-08-26 16:56:25 UTC
SUMMARY

Source code is

    for(auto x = a.begin(), y = b.begin(); *x == *y && x != a.end() && y != b.end() ; ++x, ++y ) {

Maybe better code

    for(auto x = a.begin(), y = b.begin(); x != a.end() && y != b.end() && *x == *y; ++x, ++y ) {

STEPS TO REPRODUCE
1. 
2. 
3. 

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Friedrich W. H. Kossebau 2019-08-26 17:12:24 UTC
Thanks for the patch, makes sense to me.

By what "author <email>" would you like to be referred to when committing this patch?
Comment 2 dcb314 2019-08-26 19:34:15 UTC
Thanks for giving me the choice.

David Binderman <dcb314@hotmail.com> is fine.

Since you've replied quickly, I'll have a look at more kdevelop
messages from cppcheck and report any that look like proper bugs.
Comment 3 Friedrich W. H. Kossebau 2019-08-26 20:47:17 UTC
Git commit 69e1ed669289a6927d2cf3e3b7096a649a095d8c by Friedrich W. H. Kossebau, on behalf of David Binderman.
Committed on 26/08/2019 at 20:32.
Pushed by kossebau into branch '5.4'.

Avoid possible dereference of an invalid iterator

M  +1    -1    plugins/clang/duchain/unknowndeclarationproblem.cpp

https://invent.kde.org/kde/kdevelop/commit/69e1ed669289a6927d2cf3e3b7096a649a095d8c