@cryptotaxi247 / netdata-1 / commits / 86822a55e

Use memset to mark the empty words in the quoted_strings_splitter function (#13161)

Use memset to terminate the words

Stelios Fragkakis committed Jun 16, 2022 at 22:56 UTC 86822a55ecd04d45d7371db6ede36c7a7dc84287
1 file changed +2 -4
collectors/plugins.d/plugins_d.c
+2 -4
@@ -39,7 +39,7 @@ inline int config_isspace(char c)
39 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)
40 {
41 char *s = str, quote = 0;
42 - int i = 0, j, rec = 0;
42 + int i = 0, rec = 0;
43 char *recover = recover_input;
44
45 // skip all white space
@@ -112,9 +112,7 @@ inline int quoted_strings_splitter(char *str, char **words, int max_words, int (
112 }
113
114 // terminate the words
115 - j = i;
116 - while (likely(j < max_words))
117 - words[j++] = NULL;
115 + memset(&words[i], 0, (max_words - i) * sizeof (char *));
116
117 return i;
118 }