Module: kamailio
Branch: 5.4
Commit: 3632d39b557d2b926ccfce4fd83b4c16568e6ee1
URL:
https://github.com/kamailio/kamailio/commit/3632d39b557d2b926ccfce4fd83b4c1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-03-01T18:31:01+01:00
jsonrpcs: use json null value for c null char* or str*
(cherry picked from commit c48e409b741821fa470788b3bca0ead32e4d6efc)
---
Modified: src/modules/jsonrpcs/jsonrpcs_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/3632d39b557d2b926ccfce4fd83b4c1…
Patch:
https://github.com/kamailio/kamailio/commit/3632d39b557d2b926ccfce4fd83b4c1…
---
diff --git a/src/modules/jsonrpcs/jsonrpcs_mod.c b/src/modules/jsonrpcs/jsonrpcs_mod.c
index c3b8003046..a5a92e1537 100644
--- a/src/modules/jsonrpcs/jsonrpcs_mod.c
+++ b/src/modules/jsonrpcs/jsonrpcs_mod.c
@@ -472,6 +472,7 @@ static srjson_t* jsonrpc_print_value(jsonrpc_ctx_t* ctx, char fmt,
va_list* ap)
time_t dt;
struct tm t;
str *sp;
+ char *cp;
switch(fmt) {
case 'd':
@@ -497,11 +498,20 @@ static srjson_t* jsonrpc_print_value(jsonrpc_ctx_t* ctx, char fmt,
va_list* ap)
nj = srjson_CreateString(ctx->jrpl, buf);
break;
case 's':
- nj = srjson_CreateString(ctx->jrpl, va_arg(*ap, char*));
+ cp = va_arg(*ap, char*);
+ if(cp!=NULL) {
+ nj = srjson_CreateString(ctx->jrpl, cp);
+ } else {
+ nj = srjson_CreateNull(ctx->jrpl);
+ }
break;
case 'S':
sp = va_arg(*ap, str*);
- nj = srjson_CreateStr(ctx->jrpl, sp->s, sp->len);
+ if(sp!=NULL && sp->s!=NULL) {
+ nj = srjson_CreateStr(ctx->jrpl, sp->s, sp->len);
+ } else {
+ nj = srjson_CreateNull(ctx->jrpl);
+ }
break;
default:
LM_ERR("Invalid formatting character [%c]\n", fmt);