Module: kamailio Branch: master Commit: a2bff77c3f7bfee8dae90c3ef20522d480f2e14d URL: https://github.com/kamailio/kamailio/commit/a2bff77c3f7bfee8dae90c3ef20522d4...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2024-01-19T09:44:33+01:00
jansson: declare variables at the beginning of blocks
---
Modified: src/modules/jansson/jansson_funcs.c
---
Diff: https://github.com/kamailio/kamailio/commit/a2bff77c3f7bfee8dae90c3ef20522d4... Patch: https://github.com/kamailio/kamailio/commit/a2bff77c3f7bfee8dae90c3ef20522d4...
---
diff --git a/src/modules/jansson/jansson_funcs.c b/src/modules/jansson/jansson_funcs.c index dab15d488f3..4202cd56fe8 100644 --- a/src/modules/jansson/jansson_funcs.c +++ b/src/modules/jansson/jansson_funcs.c @@ -40,6 +40,9 @@ int janssonmod_get_helper( pv_value_t dst_val; json_t *json = NULL; json_error_t parsing_error; + char *path = NULL; + char *freeme = NULL; + STR_VTOZ(src_s->s[src_s->len], c); json = json_loads(src_s->s, JSON_REJECT_DUPLICATES, &parsing_error); STR_ZTOV(src_s->s[src_s->len], c); @@ -50,14 +53,13 @@ int janssonmod_get_helper( goto fail; }
- char *path = path_s->s; + path = path_s->s;
json_t *v = json_path_get(json, path, pmode); if(!v) { goto fail; }
- char *freeme = NULL;
if(jansson_to_val(&dst_val, &freeme, v) < 0) goto fail; @@ -149,6 +151,12 @@ int janssonmod_set(unsigned int append, struct sip_msg *msg, char *type_in, char c; pv_spec_t *result_pv; pv_value_t result_val; + json_t *result_json = NULL; + json_t *value = NULL; + char *freeme = NULL; + json_error_t parsing_error = {0}; + char *endptr; + char *path = NULL;
if(fixup_get_svalue(msg, (gparam_p)type_in, &type_s) != 0) { ERR("cannot get type string value\n"); @@ -180,12 +188,6 @@ int janssonmod_set(unsigned int append, struct sip_msg *msg, char *type_in, LM_DBG("value is: %.*s\n", value_s.len, value_s.s); LM_DBG("result is: %.*s\n", result_val.rs.len, result_val.rs.s);
- json_t *result_json = NULL; - json_t *value = NULL; - char *freeme = NULL; - json_error_t parsing_error = {0}; - char *endptr; - /* check the type */ if(STR_EQ_STATIC(type_s, "object") || STR_EQ_STATIC(type_s, "obj")) { STR_VTOZ(value_s.s[value_s.len], c); @@ -260,7 +262,8 @@ int janssonmod_set(unsigned int append, struct sip_msg *msg, char *type_in, goto fail; }
- char *path = path_s.s; + path = path_s.s; + STR_VTOZ(result_val.rs.s[result_val.rs.len], c); result_json = json_loads(result_val.rs.s, JSON_REJECT_DUPLICATES, &parsing_error); @@ -300,6 +303,8 @@ int janssonmod_array_size( str path_s; pv_spec_t *dst_pv; pv_value_t dst_val; + char *path = NULL; + int size = 0;
if(fixup_get_svalue(msg, (gparam_p)src_in, &src_s) != 0) { ERR("cannot get json string value\n"); @@ -324,7 +329,7 @@ int janssonmod_array_size( goto fail; }
- char *path = path_s.s; + path = path_s.s;
json_t *v = json_path_get(json, path, 0); if(!v) { @@ -337,7 +342,7 @@ int janssonmod_array_size( goto fail; }
- int size = json_array_size(v); + size = json_array_size(v); dst_val.ri = size; dst_val.flags = PV_TYPE_INT | PV_VAL_INT;