Module: kamailio
Branch: master
Commit: 6d14b4e439aec3d046addfa776a4be5f471a33f0
URL:
https://github.com/kamailio/kamailio/commit/6d14b4e439aec3d046addfa776a4be5…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-12-08T10:23:20+01:00
lib/srdb1: rework store of long long values as number if value fits
- GH #2106
---
Modified: src/lib/srdb1/db_ut.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6d14b4e439aec3d046addfa776a4be5…
Patch:
https://github.com/kamailio/kamailio/commit/6d14b4e439aec3d046addfa776a4be5…
---
diff --git a/src/lib/srdb1/db_ut.c b/src/lib/srdb1/db_ut.c
index c7a8887044e..9975672aeea 100644
--- a/src/lib/srdb1/db_ut.c
+++ b/src/lib/srdb1/db_ut.c
@@ -610,11 +610,16 @@ int db_val2pv_spec(struct sip_msg *msg, db_val_t *dbval, pv_spec_t
*pvs)
pv.rs.len = LL_LEN;
db_longlong2str(dbval->val.ll_val, ll_buf, &pv.rs.len);
pv.rs.s = ll_buf;
- /* if it fits, also store as 32 bit integer*/
- if(!((unsigned long long)dbval->val.ll_val
- & 0xffffffff00000000ULL)) {
+ /* if it fits, also store as long number */
+ if(sizeof(long long) == sizeof(long)) {
pv.flags |= PV_VAL_INT | PV_TYPE_INT;
- pv.ri = (int)dbval->val.ll_val;
+ pv.ri = (long)dbval->val.ll_val;
+ } else {
+ if(dbval->val.ll_val >= LONG_MIN
+ && dbval->val.ll_val <= LONG_MAX) {
+ pv.flags |= PV_VAL_INT | PV_TYPE_INT;
+ pv.ri = (long)dbval->val.ll_val;
+ }
}
break;
default: