From 88e55d1b7237e6c3b5689b7ce154ef98b11fbf74 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 21 Mar 2024 22:28:44 +0100 Subject: pkgTagFile::Jump: Use lookback buffer to rejump to current position If we get called twice with the same offset, our d->Start and d->iOffset will already point at the offset for the next section. But since we have the start of the last parsed section still in the buffer, just make sure to always go back to the start first. Closes: #1067440 --- apt-pkg/tagfile.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 8f323bb5a..95ae4a483 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -431,6 +431,11 @@ bool pkgTagFile::Fill() that is there */ bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long long Offset) { + // Head back to the start of the buffer, in case we get called for the same section + // again (d->Start will point to next section already) + d->iOffset -= d->Start - d->Buffer; + d->Start = d->Buffer; + if ((d->Flags & pkgTagFile::SUPPORT_COMMENTS) == 0 && // We are within a buffer space of the next hit.. Offset >= d->iOffset && d->iOffset + (d->End - d->Start) > Offset) -- cgit v1.2.3-70-g09d2