https://github.com/ChuvakHome created https://github.com/llvm/llvm-project/pull/117226
Fix for some mistakes in source code found using PVS Studio. Inspired by: https://pvs-studio.com/en/blog/posts/cpp/1188/ Fixed: - [Bug 8](https://pvs-studio.com/en/blog/posts/cpp/1188/#ID0EFA5EA398) - [Bug 10](https://pvs-studio.com/en/blog/posts/cpp/1188/#ID0BFC185CF3) >From 5aa27e834cc78f329b9d5abd39529f7b5445f74b Mon Sep 17 00:00:00 2001 From: timurdemenev <311...@niuitmo.ru> Date: Thu, 21 Nov 2024 22:56:13 +0300 Subject: [PATCH] Fix index boundaries check, Change wrong int literal --- .../ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 2 +- lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 0083b499656979..c43871b08191db 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -3278,7 +3278,7 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA( } // If the index is still out of range then this isn't a pointer. - if (index > m_indexed_isa_cache.size()) + if (index >= m_indexed_isa_cache.size()) return false; LLDB_LOGF(log, "AOCRT::NPI Evaluate(ret_isa = 0x%" PRIx64 ")", diff --git a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp index 8c69989702c2aa..f7a2d1d07142ec 100644 --- a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp +++ b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp @@ -150,7 +150,7 @@ GeneratePerfEventConfigValue(bool enable_tsc, if (enable_tsc) { if (Expected<uint32_t> offset = ReadIntelPTConfigFile( kTSCBitOffsetFile, IntelPTConfigFileType::BitOffset)) - config |= 1 << *offset; + config |= 1ULL << *offset; else return offset.takeError(); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits