[devel] [PATCH for apt v2 21/21] Fix invalid check of Queue against zero

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


Queue must not be zero in this function, otherwise it'd crash in this function
anyway, since it's used like it's never zero later.
Found via clang-static-analyzer:
Logic error: Called C++ object pointer is null:
Called C++ object pointer is null
---
 apt/apt-pkg/acquire-method.cc | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/apt/apt-pkg/acquire-method.cc b/apt/apt-pkg/acquire-method.cc
index 9a3ef1d..3b5c580 100644
--- a/apt/apt-pkg/acquire-method.cc
+++ b/apt/apt-pkg/acquire-method.cc
@@ -555,9 +555,7 @@ void pkgAcqMethod::Warning(const char *Format,...)
    to keep the pipeline synchronized. */
 void pkgAcqMethod::Redirect(const string &NewURI)
 {
-   string CurrentURI = "<UNKNOWN>";
-   if (Queue != 0)
-      CurrentURI = Queue->Uri;
+   string CurrentURI = Queue->Uri;
 
    ostringstream s;
    s << "103 Redirect\nURI: " << CurrentURI << "\nNew-URI: " << NewURI 
-- 
2.24.1



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