MXS-1456: Fix crash on empty script value
If a script variable resolves to an empty string, the replacement attempt will fail with an out-of-memory error. The following realloc call will fail as it requires a positive value for the new size.
This commit is contained in:
parent
df4f3cb302
commit
f06c34f66c
@ -220,10 +220,12 @@ bool externcmd_substitute_arg(EXTERNCMD* cmd, const char* match, const char* rep
|
||||
size_t size_orig = strlen(cmd->argv[i]);
|
||||
size_t size_replace = strlen(replace);
|
||||
size_t size = MXS_MAX(size_orig, size_replace);
|
||||
char* dest = MXS_MALLOC(size);
|
||||
if (dest)
|
||||
char* dest;
|
||||
|
||||
if (size && (dest = MXS_MALLOC(size)))
|
||||
{
|
||||
mxs_pcre2_result_t rc = mxs_pcre2_substitute(re, cmd->argv[i], replace, &dest, &size);
|
||||
|
||||
switch (rc)
|
||||
{
|
||||
case MXS_PCRE2_ERROR:
|
||||
|
Loading…
x
Reference in New Issue
Block a user