From d6753d89147605fb1199ed15701714f084febc4c Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Thu, 13 Oct 2022 17:47:06 +0200 Subject: [PATCH] uucore: remove string leak in format_usage --- src/uucore/src/lib/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index e216b8fe3..5780092be 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -98,10 +98,10 @@ macro_rules! bin { /// Generate the usage string for clap. /// /// This function replaces all occurrences of `{}` with the execution phrase -/// and leaks the result to return a `&'static str`. It does **not** support +/// and returns the resulting `String`. It does **not** support /// more advanced formatting features such as `{0}`. -pub fn format_usage(s: &str) -> &'static str { - &*Box::leak(s.replace("{}", crate::execution_phrase()).into_boxed_str()) +pub fn format_usage(s: &str) -> String { + s.replace("{}", crate::execution_phrase()) } pub fn get_utility_is_second_arg() -> bool {