commit: ff773ed5a95fe7d6891455dbee7cd686c4ceef97
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 9 10:27:41 2019 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov 9 10:27:41 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ff773ed5
libq/tree: fix crash in tree_get_atom for ebuild mode with SLOT
When an ebuild doesn't contain SLOT, but it was requested, just set SLOT
to NULL, instead of trying to strdup(NULL).
Thanks Joakim Tjernlund
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
libq/tree.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libq/tree.c b/libq/tree.c
index a8baabe..b0d0b5b 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -1014,8 +1014,10 @@ tree_get_atom(tree_pkg_ctx *pkg_ctx, bool complete)
if (pkg_ctx->slot == NULL) {
tree_pkg_meta *meta =
tree_pkg_read(pkg_ctx);
if (meta != NULL) {
- pkg_ctx->slot =
xstrdup(meta->SLOT);
- pkg_ctx->slot_len =
strlen(pkg_ctx->slot);
+ if (meta->SLOT != NULL) {
+ pkg_ctx->slot =
xstrdup(meta->SLOT);
+ pkg_ctx->slot_len =
strlen(pkg_ctx->slot);
+ }
tree_close_meta(meta);
}
}