pvs-studio: (V522) Prevent possible null-pointer dereference in RemoveRPathELF

This commit is contained in:
Martin Duffy
2026-06-17 10:13:12 -04:00
parent 77b874baa8
commit e2f4b9bedc
2 changed files with 2 additions and 3 deletions
-2
View File
@@ -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.
+2 -1
View File
@@ -3889,7 +3889,8 @@ static cm::optional<bool> 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]);
}