-
Incident report
-
Resolution: Fixed
-
Minor
-
3.0.5
-
Sprint 1, Sprint 2, Sprint 3
-
5
We have the following function in src/libs/zbxserver/expression.c:
/****************************************************************************** * * * Function: expand_trigger_description_constants * * * * Purpose: substitute simple macros in data string with real values * * * * Parameters: data - trigger description * * * ******************************************************************************/ static void expand_trigger_description_constants(char **data, const char *expression) { char **numbers = NULL, *new_str = NULL, replace[3] = "$0"; int numbers_cnt = 0, i = 0; numbers = extract_numbers(expression, &numbers_cnt); for (i = 0; i < 9; i++) { replace[1] = '0' + i + 1; new_str = string_replace(*data, replace, i < numbers_cnt ? numbers[i] : ""); zbx_free(*data); *data = new_str; } zbx_free_numbers(&numbers, numbers_cnt); }
It seems to perform at least 10 string allocations, even if they are not required. This should be optimized.