From 34b6baf94093aee716c7592c981867b58f0fcde0 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sun, 4 Sep 2016 18:18:52 +0300 Subject: Fix crash on uninstall --- build2/install/rule.cxx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx index d43ef14..ebab282 100644 --- a/build2/install/rule.cxx +++ b/build2/install/rule.cxx @@ -685,10 +685,13 @@ namespace build2 else #endif { - const char* args[] = {base.sudo->c_str (), - "rmdir", - reld.string ().c_str (), - nullptr}; + const char* args_a[] = { + base.sudo != nullptr ? base.sudo->c_str () : nullptr, + "rmdir", + reld.string ().c_str (), + nullptr}; + + const char** args (&args_a[base.sudo == nullptr ? 1 : 0]); if (verb >= 2) print_process (args); @@ -780,11 +783,14 @@ namespace build2 else #endif { - const char* args[] = {base.sudo->c_str (), - "rm", - "-f", - relf.string ().c_str (), - nullptr}; + const char* args_a[] = { + base.sudo != nullptr ? base.sudo->c_str () : nullptr, + "rm", + "-f", + relf.string ().c_str (), + nullptr}; + + const char** args (&args_a[base.sudo == nullptr ? 1 : 0]); if (verb >= 2) print_process (args); -- cgit v1.1