summaryrefslogtreecommitdiffstats
path: root/collectors
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2022-06-16 22:56:14 +0300
committerGitHub <noreply@github.com>2022-06-16 22:56:14 +0300
commit86822a55ecd04d45d7371db6ede36c7a7dc84287 (patch)
tree30f803555d81710390167445cc3a2d76420eb025 /collectors
parent100a12c6cc01222b1518e5e50d2147f592d8a111 (diff)
Use memset to mark the empty words in the quoted_strings_splitter function (#13161)
Use memset to terminate the words
Diffstat (limited to 'collectors')
-rw-r--r--collectors/plugins.d/plugins_d.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/collectors/plugins.d/plugins_d.c b/collectors/plugins.d/plugins_d.c
index 2916f1c13f..377ec1401f 100644
--- a/collectors/plugins.d/plugins_d.c
+++ b/collectors/plugins.d/plugins_d.c
@@ -39,7 +39,7 @@ inline int config_isspace(char c)
inline int quoted_strings_splitter(char *str, char **words, int max_words, int (*custom_isspace)(char), char *recover_input, char **recover_location, int max_recover)
{
char *s = str, quote = 0;
- int i = 0, j, rec = 0;
+ int i = 0, rec = 0;
char *recover = recover_input;
// skip all white space
@@ -112,9 +112,7 @@ inline int quoted_strings_splitter(char *str, char **words, int max_words, int (
}
// terminate the words
- j = i;
- while (likely(j < max_words))
- words[j++] = NULL;
+ memset(&words[i], 0, (max_words - i) * sizeof (char *));
return i;
}