Return NULL if no regex parameter is defined
If no regex type parameters are defined and a compiled pattern is requested, the function will return a NULL value. This allows code that directly calls the config_get_compiled_regex function to work without doing additional checks for the presence of optional parameters.
This commit is contained in:
@ -1244,9 +1244,16 @@ pcre2_code* config_get_compiled_regex(const MXS_CONFIG_PARAMETER *params,
|
|||||||
uint32_t* output_ovec_size)
|
uint32_t* output_ovec_size)
|
||||||
{
|
{
|
||||||
const char* regex_string = config_get_string(params, key);
|
const char* regex_string = config_get_string(params, key);
|
||||||
|
pcre2_code* code = NULL;
|
||||||
|
|
||||||
|
if (*regex_string)
|
||||||
|
{
|
||||||
uint32_t jit_available = 0;
|
uint32_t jit_available = 0;
|
||||||
pcre2_config(PCRE2_CONFIG_JIT, &jit_available);
|
pcre2_config(PCRE2_CONFIG_JIT, &jit_available);
|
||||||
return compile_regex_string(regex_string, jit_available, options, output_ovec_size);
|
code = compile_regex_string(regex_string, jit_available, options, output_ovec_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
MXS_CONFIG_PARAMETER* config_clone_param(const MXS_CONFIG_PARAMETER* param)
|
MXS_CONFIG_PARAMETER* config_clone_param(const MXS_CONFIG_PARAMETER* param)
|
||||||
|
|||||||
Reference in New Issue
Block a user