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
(cherry picked from commit 056f1ae610)
mr10.4.1
Richard Fuchs 4 years ago
parent 2d2cdd0b42
commit 6b3eba0902

16
cdr.c

@ -1302,17 +1302,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