Module: sip-router
Branch: 3.3
Commit: 7fab57ff91fc395c1450503706b3f734fb9473c3
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7fab57f…
Author: Richard Brady <rnbrady(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Jan 22 17:19:31 2013 +0100
json: proper handling of empty values for json documents
(cherry picked from commit 15e1ae6720136a698326a0b53f6db8eef73e3e5a)
---
modules/json/json_funcs.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/modules/json/json_funcs.c b/modules/json/json_funcs.c
index 1c42656..a75704b 100644
--- a/modules/json/json_funcs.c
+++ b/modules/json/json_funcs.c
@@ -51,6 +51,12 @@ int json_get_field(struct sip_msg* msg, char* json, char* field, char*
dst)
dst_pv = (pv_spec_t *)dst;
struct json_object *j = json_tokener_parse(json_s.s);
+
+ if (is_error(j)) {
+ LM_ERR("empty or invalid JSON\n");
+ return -1;
+ }
+
char *value = (char*)json_object_to_json_string(json_object_object_get(j, field_s.s));
dst_val.rs.s = value;