diff options
author | Dmitrijs Goloscapovs <dmitrijs.goloscapovs@zabbix.com> | 2022-01-07 17:35:46 +0300 |
---|---|---|
committer | Dmitrijs Goloscapovs <dmitrijs.goloscapovs@zabbix.com> | 2022-01-07 17:35:46 +0300 |
commit | a73c22b2900914abef18bc49600c031e17fb5ea3 (patch) | |
tree | 64c4d180e6b078f1be55deef737db3718f792eb0 /src/libs/zbxembed | |
parent | 59a8a452203cc2749165f0f3723bcf5cf78facb0 (diff) |
.......PS. [ZBX-20405] refactored
Diffstat (limited to 'src/libs/zbxembed')
-rw-r--r-- | src/libs/zbxembed/xml.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/libs/zbxembed/xml.c b/src/libs/zbxembed/xml.c index 0e4165845c0..6e7804c80c4 100644 --- a/src/libs/zbxembed/xml.c +++ b/src/libs/zbxembed/xml.c @@ -88,8 +88,14 @@ out: ******************************************************************************/ static duk_ret_t es_xml_from_json(duk_context *ctx) { - int err_index = -1; - char *str = NULL, *error = NULL; + int err_index = -1; + char *str = NULL, *error = NULL; + zbx_es_env_t *env; + + if (NULL == (env = zbx_es_get_env(ctx))) + return duk_error(ctx, DUK_RET_TYPE_ERROR, "cannot access internal environment"); + + ZBX_ES_CHECK_TIMEOUT(ctx, env); if (FAIL == zbx_json_to_xml((char *)duk_safe_to_string(ctx, 0), &str, &error)) { @@ -116,8 +122,14 @@ out: ******************************************************************************/ static duk_ret_t es_xml_to_json(duk_context *ctx) { - int err_index = -1; - char *str = NULL, *error = NULL; + int err_index = -1; + char *str = NULL, *error = NULL; + zbx_es_env_t *env; + + if (NULL == (env = zbx_es_get_env(ctx))) + return duk_error(ctx, DUK_RET_TYPE_ERROR, "cannot access internal environment"); + + ZBX_ES_CHECK_TIMEOUT(ctx, env); if (FAIL == zbx_xml_to_json((char *)duk_safe_to_string(ctx, 0), &str, &error)) { |