1 |
commit: e575a3259cc0d74972359315f549f27372e1f6b6 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jan 2 13:22:22 2020 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 2 13:22:22 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e575a325 |
7 |
|
8 |
libq/tree: fix bug after realloc in metadata Q__data |
9 |
|
10 |
don't reposition the Q__data pointer itself, it was already updated to |
11 |
the new value |
12 |
|
13 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
14 |
|
15 |
libq/tree.c | 7 ++++--- |
16 |
1 file changed, 4 insertions(+), 3 deletions(-) |
17 |
|
18 |
diff --git a/libq/tree.c b/libq/tree.c |
19 |
index 570859e..e7914f1 100644 |
20 |
--- a/libq/tree.c |
21 |
+++ b/libq/tree.c |
22 |
@@ -922,7 +922,7 @@ tree_read_file_binpkg_xpak_cb( |
23 |
if (old_data != NULL && m->Q__data != old_data) { |
24 |
char **newdata = (char **)m; |
25 |
int elems = sizeof(tree_pkg_meta) / sizeof(char *); |
26 |
- while (elems-- > 0) |
27 |
+ while (elems-- > 1) /* skip Q__data itself */ |
28 |
if (newdata[elems] != NULL) |
29 |
newdata[elems] = m->Q__data + (newdata[elems] - old_data); |
30 |
} |
31 |
@@ -999,7 +999,8 @@ tree_pkg_meta_get_int(tree_pkg_ctx *pkg_ctx, size_t offset, const char *keyn) |
32 |
char **key; |
33 |
|
34 |
/* offset is a byte offset in the tree_pkg_meta struct, pointing to |
35 |
- * key, the tree_pkg_meta_get macro takes care of this */ |
36 |
+ * key, the tree_pkg_meta_get macro as called by the user takes care |
37 |
+ * of offset and keyn pointing to the same thing */ |
38 |
|
39 |
if (ctx->cachetype == CACHE_VDB) { |
40 |
if (pkg_ctx->meta == NULL) |
41 |
@@ -1037,7 +1038,7 @@ tree_pkg_meta_get_int(tree_pkg_ctx *pkg_ctx, size_t offset, const char *keyn) |
42 |
if (old_data != NULL && m->Q__data != old_data) { |
43 |
char **newdata = (char **)m; |
44 |
int elems = sizeof(tree_pkg_meta) / sizeof(char *); |
45 |
- while (elems-- > 0) |
46 |
+ while (elems-- > 1) /* skip Q__data itself */ |
47 |
if (newdata[elems] != NULL) |
48 |
newdata[elems] = |
49 |
m->Q__data + (newdata[elems] - old_data); |