TT#182200 fix mem leak

json_tokener_parse returns a newly created JSON object (tree) which must
be freed by decreasing the ref count before the variable goes out of
scope.

Fix-up for Ia7e8446fe4953d1391f99ea1530990e3d385c056

Change-Id: I2e4b17086df468f66401a71a836d37ed821944e5
mr11.0
Richard Fuchs 3 years ago
parent 4b99ab1d2b
commit 95243fed19

16
cdr.c

@ -1294,17 +1294,25 @@ static int validate_src_dst_leg(med_entry_t *e)
return -1;
}
int invalid;
json_object *json_src_leg = json_tokener_parse(e->src_leg);
if (!(json_src_leg && json_object_is_type(json_src_leg, json_type_object)) &&
strchr(e->src_leg, MED_SEP) == NULL)
invalid = (!(json_src_leg && json_object_is_type(json_src_leg, json_type_object)) &&
strchr(e->src_leg, MED_SEP) == NULL);
if (json_src_leg)
json_object_put(json_src_leg);
if (invalid)
{
L_DEBUG("Invalid src_leg");
return -1;
}
json_object *json_dst_leg = json_tokener_parse(e->dst_leg);
if (!(json_dst_leg && json_object_is_type(json_dst_leg, json_type_object)) &&
strchr(e->dst_leg, MED_SEP) == NULL)
invalid = (!(json_dst_leg && json_object_is_type(json_dst_leg, json_type_object)) &&
strchr(e->dst_leg, MED_SEP) == NULL);
if (json_dst_leg)
json_object_put(json_dst_leg);
if (invalid)
{
L_DEBUG("Invalid dst_leg");
return -1;

Loading…
Cancel
Save