From e1284a59de37efeedcc998ef61e8466c35b82eb2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 14 May 2012 16:53:43 +0200 Subject: * apt-pkg/acquire-methods.cc: - factor out into private Dequeue() to fix access to deleted pointer --- apt-pkg/acquire-method.cc | 23 ++++++++++------------- apt-pkg/acquire-method.h | 3 +++ debian/changelog | 2 ++ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index 2041fd9e9..e6e02bbc5 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -95,12 +95,7 @@ void pkgAcqMethod::Fail(string Err,bool Transient) { std::cout << "400 URI Failure\nURI: " << Queue->Uri << "\n" << "Message: " << Err << " " << IP << "\n"; - // Dequeue - FetchItem *Tmp = Queue; - Queue = Queue->Next; - delete Tmp; - if (Tmp == QueueBack) - QueueBack = Queue; + Dequeue(); } else std::cout << "400 URI Failure\nURI: \nMessage: " << Err << "\n"; @@ -211,13 +206,7 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt) } std::cout << "\n" << std::flush; - - // Dequeue - FetchItem *Tmp = Queue; - Queue = Queue->Next; - delete Tmp; - if (Tmp == QueueBack) - QueueBack = Queue; + Dequeue(); } /*}}}*/ // AcqMethod::MediaFail - Syncronous request for new media /*{{{*/ @@ -465,3 +454,11 @@ void pkgAcqMethod::FetchResult::TakeHashes(Hashes &Hash) SHA512Sum = Hash.SHA512.Result(); } /*}}}*/ +void pkgAcqMethod::Dequeue() { /*{{{*/ + FetchItem const * const Tmp = Queue; + Queue = Queue->Next; + if (Tmp == QueueBack) + QueueBack = Queue; + delete Tmp; +} + /*}}}*/ diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index 2dd9ad685..00f99e0a0 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -104,6 +104,9 @@ class pkgAcqMethod pkgAcqMethod(const char *Ver,unsigned long Flags = 0); virtual ~pkgAcqMethod() {}; + + private: + void Dequeue(); }; /** @} */ diff --git a/debian/changelog b/debian/changelog index f0a6aba3b..7097a6e99 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,8 @@ apt (0.9.4) UNRELEASED; urgency=low * debian/control: - move doxygen and debiandoc-sgml to Build-Depends-Indep as docs are no longer build in the same target as the manpages + * apt-pkg/acquire-methods.cc: + - factor out into private Dequeue() to fix access to deleted pointer -- David Kalnischkies Fri, 11 May 2012 23:26:59 +0200 -- cgit v1.2.3