From 2bee36605c38ead9c2b6d978e757e39d426a4d34 Mon Sep 17 00:00:00 2001 From: meag Date: Sat, 18 Apr 2020 09:50:18 +0100 Subject: [PATCH] ALIASEDIT: Fix random characters appearing at end --- cmd.c | 15 +++++++-------- release-notes.md | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd.c b/cmd.c index e45da5257..305147fe4 100644 --- a/cmd.c +++ b/cmd.c @@ -712,16 +712,15 @@ void Cmd_EditAlias_f (void) } a = Cmd_FindAlias(Cmd_Argv(1)); - if ( a == NULL ) { - s = Q_strdup(""); - } else { - s = Q_strdup(a->value); - } + s = (a ? a->value : ""); - snprintf(final_string, sizeof(final_string), "/alias \"%s\" \"%s\"", Cmd_Argv(1), s); + strlcpy(final_string, "/alias \"", sizeof(final_string)); + strlcat(final_string, Cmd_Argv(1), sizeof(final_string)); + strlcat(final_string, "\" \"", sizeof(final_string)); + strlcat(final_string, s, sizeof(final_string)); + strlcat(final_string, "\"", sizeof(final_string)); Key_ClearTyping(); - memcpy (key_lines[edit_line]+1, str2wcs(final_string), strlen(final_string)*sizeof(wchar)); - Q_free(s); + memcpy(key_lines[edit_line]+1, str2wcs(final_string), (strlen(final_string) + 1) * sizeof(wchar)); } static cmd_alias_t* Cmd_AliasCreate (char* name) diff --git a/release-notes.md b/release-notes.md index 897f69fa6..8545a9f5c 100644 --- a/release-notes.md +++ b/release-notes.md @@ -65,6 +65,7 @@ - {} white-text wasn't stripped from item name cvars - Halflife maps had wrong bounding box sizes - `hud_sortrules_includeself 0` could lead to player not being included in visible list +- `aliasedit` could result in the end of previously entered text to appear at end of line ### Other changes