From 4b434cde19d25e2acc238699834f1a2a72540ca2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 5 Mar 2010 18:14:43 +0100 Subject: * python/tag.cc: - Hack the TagFile iterator to not use shared storage (Closes: #572596): Scan once, duplicate the section data, and scan again. --- python/tag.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'python') diff --git a/python/tag.cc b/python/tag.cc index 6d327d27..c7edcb31 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -271,6 +271,22 @@ static PyObject *TagFileNext(PyObject *Self) Obj.Section->Data = 0; if (Obj.Object.Step(Obj.Section->Object) == false) return HandleErrors(NULL); + + // Bug-Debian: http://bugs.debian.org/572596 + // Duplicate the data here and scan the duplicated section data; in order + // to not use any shared storage. + // TODO: Provide an API in apt-pkg to do this; this is really ugly. + + // Fetch old section data + const char *Start; + const char *Stop; + Obj.Section->Object.GetSection(Start,Stop); + // Duplicate the data + Obj.Section->Data = new char[Stop-Start]; + strncpy(Obj.Section->Data, Start, Stop-Start); + // Rescan it + Obj.Section->Object.Scan(Obj.Section->Data, Stop-Start); + Py_INCREF(Obj.Section); return HandleErrors(Obj.Section); } -- cgit v1.2.3