diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2016-09-04 18:18:52 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2016-09-04 18:18:52 +0300 |
commit | 34b6baf94093aee716c7592c981867b58f0fcde0 (patch) | |
tree | 2cbce03f08d76607dac5fcfbabf5b14a496f93c5 | |
parent | fb5954f7b08c98eee41a2b59a1e89ab10569510a (diff) |
Fix crash on uninstall
-rw-r--r-- | build2/install/rule.cxx | 24 |
1 files 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); |