Module: kamailio
Branch: master
Commit: 17b9a6add82781f71b4d84da7c804e0e72c8b026
URL:
https://github.com/kamailio/kamailio/commit/17b9a6add82781f71b4d84da7c804e0…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-03-01T18:47:42+01:00
xmlrpc: use <nil/> for null string values
- XML-RPC extension listed at
https://en.wikipedia.org/wiki/XML-RPC#Data_types
---
Modified: src/modules/xmlrpc/xmlrpc.c
---
Diff:
https://github.com/kamailio/kamailio/commit/17b9a6add82781f71b4d84da7c804e0…
Patch:
https://github.com/kamailio/kamailio/commit/17b9a6add82781f71b4d84da7c804e0…
---
diff --git a/src/modules/xmlrpc/xmlrpc.c b/src/modules/xmlrpc/xmlrpc.c
index dd64cf06f9..5e2a7466b0 100644
--- a/src/modules/xmlrpc/xmlrpc.c
+++ b/src/modules/xmlrpc/xmlrpc.c
@@ -264,6 +264,7 @@ static str member_prefix =
STR_STATIC_INIT("<member>");
static str member_suffix = STR_STATIC_INIT("</member>");
static str name_prefix = STR_STATIC_INIT("<name>");
static str name_suffix = STR_STATIC_INIT("</name>");
+static str nil_value = STR_STATIC_INIT("<nil/>");
/** Garbage collection data structure.
*
@@ -1066,17 +1067,29 @@ static int print_value(struct xmlrpc_reply* res,
break;
case 's':
- prefix = string_prefix;
- suffix = string_suffix;
body.s = va_arg(*ap, char*);
- body.len = strlen(body.s);
+ if(body.s!=NULL) {
+ prefix = string_prefix;
+ suffix = string_suffix;
+ body.len = strlen(body.s);
+ } else {
+ prefix = "";
+ suffix = "";
+ body = nil_value;
+ }
break;
case 'S':
- prefix = string_prefix;
- suffix = string_suffix;
sp = va_arg(*ap, str*);
- body = *sp;
+ if(sp!=NULL && sp->s!=NULL) {
+ prefix = string_prefix;
+ suffix = string_suffix;
+ body = *sp;
+ } else {
+ prefix = "";
+ suffix = "";
+ body = nil_value;
+ }
break;
default: