llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Shivam Gupta (xgupta) <details> <summary>Changes</summary> This PR address the issue reported by static analyser cppcheck regarding missing bounds check for extra iterator increment in a loop. This could lead to accessing out-of-bounds memory. To fix this we have adjusted the loop conditions to not incrementing iterator c there. Caught by cppcheck - lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:1300:75: warning: Missing bounds check for extra iterator increment in loop. [StlMissingComparison] Fix #<!-- -->91225 --- Full diff: https://github.com/llvm/llvm-project/pull/94844.diff 1 Files Affected: - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (+2-1) ``````````diff diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 8a47eed3d7cbe..81644d6248a83 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -1297,7 +1297,7 @@ std::string GDBRemoteCommunication::ExpandRLE(std::string packet) { // Reserve enough byte for the most common case (no RLE used). std::string decoded; decoded.reserve(packet.size()); - for (std::string::const_iterator c = packet.begin(); c != packet.end(); ++c) { + for (std::string::const_iterator c = packet.begin(); c != packet.end();) { if (*c == '*') { // '*' indicates RLE. Next character will give us the repeat count and // previous character is what is to be repeated. @@ -1316,6 +1316,7 @@ std::string GDBRemoteCommunication::ExpandRLE(std::string packet) { } else { decoded.push_back(*c); } + c++; } return decoded; } `````````` </details> https://github.com/llvm/llvm-project/pull/94844 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits