aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/sign.c
diff options
context:
space:
mode:
authorThomas Vigouroux <thomas.vigouroux@protonmail.com>2022-06-24 08:29:15 +0200
committerThomas Vigouroux <thomas.vigouroux@protonmail.com>2022-06-27 06:55:41 +0200
commit89f75dcd1f779a93936c90c7a124c2983c018df0 (patch)
tree26efcd5195d8a8cd2ecfdcd86bf7d18b6d79cfe0 /src/nvim/sign.c
parentfd3008a6aeba743080d0452b326e929786c57eb7 (diff)
downloadrneovim-89f75dcd1f779a93936c90c7a124c2983c018df0.tar.gz
rneovim-89f75dcd1f779a93936c90c7a124c2983c018df0.tar.bz2
rneovim-89f75dcd1f779a93936c90c7a124c2983c018df0.zip
fix(coverity/348300): free memory when overiding sing attribute
Nothing prevent the user from doing `:sign define abc culhl=Normal culhl=Normal` and thus this leads to an obvious memory leak.
Diffstat (limited to 'src/nvim/sign.c')
-rw-r--r--src/nvim/sign.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index a5adc48540..0e4d092025 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -1176,21 +1176,27 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
p = skiptowhite_esc(arg);
if (STRNCMP(arg, "icon=", 5) == 0) {
arg += 5;
+ XFREE_CLEAR(icon);
icon = vim_strnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "text=", 5) == 0) {
arg += 5;
+ XFREE_CLEAR(text);
text = vim_strnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "linehl=", 7) == 0) {
arg += 7;
+ XFREE_CLEAR(linehl);
linehl = vim_strnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "texthl=", 7) == 0) {
arg += 7;
+ XFREE_CLEAR(texthl);
texthl = vim_strnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "culhl=", 6) == 0) {
arg += 6;
+ XFREE_CLEAR(culhl);
culhl = vim_strnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "numhl=", 6) == 0) {
arg += 6;
+ XFREE_CLEAR(numhl);
numhl = vim_strnsave(arg, (size_t)(p - arg));
} else {
semsg(_(e_invarg2), arg);