From f324a1a432b02137cab73978fe5df5e11005d938 Mon Sep 17 00:00:00 2001 From: Vlad Paiu Date: Tue, 3 Dec 2024 11:18:05 +0000 Subject: [PATCH] Add support for bigints ( store as string when exposing to opensips script ) --- modules/json/json.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/json/json.c b/modules/json/json.c index 9fdbd20b8e8..35fef714652 100644 --- a/modules/json/json.c +++ b/modules/json/json.c @@ -457,10 +457,16 @@ int pv_get_json_ext(struct sip_msg* msg, pv_param_t* pvp, pv_value_t* val, int if( json_object_is_type(obj, json_type_int) ) { - val->rs.s = sint2str(json_object_get_int(obj), &val->rs.len); - val->ri = json_object_get_int(obj);; - val->flags |= PV_VAL_INT|PV_TYPE_INT|PV_VAL_STR; - + int_value = json_object_get_int64(obj); + val->rs.s = sint2str(int_value, &val->rs.len); + if (int_value<=INT_MAX && int_value>=INT_MIN) { + /* safe to store it as an INT in the pvar */ + val->ri = int_value;; + val->flags |= PV_VAL_INT|PV_TYPE_INT|PV_VAL_STR; + } else { + /* we would overflow/underflow, store as string only */ + val->flags |= PV_VAL_STR; + } } else if( json_object_is_type(obj, json_type_string)) {