[devel] [PATCH for apt v2 20/21] Get rid of dangling invalid pointer

Aleksei Nikiforov darktemplar на altlinux.org
Чт Дек 12 12:57:29 MSK 2019


Found via clang-static-analyzer:
Logic error: Stack address stored into global variable:
Address of stack memory associated with local variable 'Fix' is still
referred to by the global variable 'This' upon returning to the caller.
This will be a dangling reference
---
 apt/apt-pkg/algorithms.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/apt/apt-pkg/algorithms.cc b/apt/apt-pkg/algorithms.cc
index 772f609..2c9208c 100644
--- a/apt/apt-pkg/algorithms.cc
+++ b/apt/apt-pkg/algorithms.cc
@@ -960,6 +960,9 @@ pkgProblemResolver::~pkgProblemResolver()
 {
    delete [] Scores;
    delete [] Flags;
+
+   if (This == this)
+      This = nullptr;
 }
 									/*}}}*/
 // ProblemResolver::ScoreSort - Sort the list by score			/*{{{*/
-- 
2.24.1



Подробная информация о списке рассылки Devel