From e3cf44824b93c250ca8b5ee98b6149437ae2c68a Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 20 Jun 2024 20:34:15 +0300 Subject: Fix crashing of $install.resolve() on absolute paths (GH issue #393) --- libbuild2/install/rule.cxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'libbuild2/install/rule.cxx') diff --git a/libbuild2/install/rule.cxx b/libbuild2/install/rule.cxx index 873b2e9..1aa21d0 100644 --- a/libbuild2/install/rule.cxx +++ b/libbuild2/install/rule.cxx @@ -871,16 +871,16 @@ namespace build2 r->sudo = cast_null (s["config.install.sudo"]); if (r->cmd == nullptr) - r->cmd = &cast (s["config.install.cmd"]); + r->cmd = cast_null (s["config.install.cmd"]); if (r->options == nullptr) r->options = cast_null (s["config.install.options"]); if (r->mode == nullptr) - r->mode = &cast (s["config.install.mode"]); + r->mode = cast_null (s["config.install.mode"]); if (r->dir_mode == nullptr) - r->dir_mode = &cast (s["config.install.dir_mode"]); + r->dir_mode = cast_null (s["config.install.dir_mode"]); return rs; } @@ -1064,6 +1064,10 @@ namespace build2 if (base.sudo != nullptr) args.push_back (base.sudo->c_str ()); + // Wouldn't be here otherwise. + // + assert (base.cmd != nullptr && base.dir_mode != nullptr); + args.push_back (base.cmd->string ().c_str ()); args.push_back ("-d"); @@ -1129,6 +1133,10 @@ namespace build2 if (base.sudo != nullptr) args.push_back (base.sudo->c_str ()); + // Wouldn't be here otherwise. + // + assert (base.cmd != nullptr && base.mode != nullptr); + args.push_back (base.cmd->string ().c_str ()); if (base.options != nullptr) -- cgit v1.1