summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2024-03-21 22:28:44 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2024-03-21 22:31:04 +0100
commit88e55d1b7237e6c3b5689b7ce154ef98b11fbf74 (patch)
tree92f91edd8bc614c0f7fc62b326c2ca4dff380bb9 /apt-pkg
parent92dfc56a541894e293019920fe9031ae4d42fb29 (diff)
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
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/tagfile.cc5
1 files changed, 5 insertions, 0 deletions
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)