From e2f4b9bedcfbec39dde8f0a4d0fb52c80168aef8 Mon Sep 17 00:00:00 2001 From: Martin Duffy Date: Mon, 18 May 2026 02:07:53 -0400 Subject: [PATCH] pvs-studio: (V522) Prevent possible null-pointer dereference in RemoveRPathELF --- .pvsconfig | 2 -- Source/cmSystemTools.cxx | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.pvsconfig b/.pvsconfig index df665de4df..2cb7888fa0 100644 --- a/.pvsconfig +++ b/.pvsconfig @@ -6,8 +6,6 @@ //-V::508 # The 'x' variable is assigned values twice successively. Perhaps this is a mistake. //-V::519 -# Possible null pointer dereference. -//-V::522 # Constant value is represented by an octal form. //-V::536 # Iterators are passed as arguments to 'Foo' function. Consider inspecting the expression. diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 79767575ea..d7a71f04a6 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -3889,7 +3889,8 @@ static cm::optional RemoveRPathELF(std::string const& file, // There is no RPATH or RUNPATH anyway. return true; } - if (se_count == 2 && se[1]->IndexInSection < se[0]->IndexInSection) { + if (se_count == 2 && se[0] && se[1] && + se[1]->IndexInSection < se[0]->IndexInSection) { std::swap(se[0], se[1]); }