-
Problem report
-
Resolution: Fixed
-
Trivial
-
None
-
None
-
Sprint 71 (Dec 2020)
-
0.125
The following error occurs on Windows when attempting to use string_replace function though may happen on some other exotic platform:
file:..\..\..\src\libs\zbxcommon\str.c,line:388 zbx_malloc: out of memory. Requested 4294967614 bytes.
Diff is signed, while count is unsigned.
long diff; unsigned long count = 0;
Diff can be negative:
diff = (long)strlen(sub_str2) - len; /* allocate new memory */
Diff is add to strlen, however count is unsigned so count*diff may become large number in my case 4294967614 which is larger then maximum unsigned long type.
new_str = (char *)zbx_malloc(new_str, (size_t)(strlen(str) + count*diff + 1)*sizeof(char));