diff options
author | Li Xiaoming <lixm.fnst@cn.fujitsu.com> | 2021-01-13 19:42:37 +0800 |
---|---|---|
committer | Li Xiaoming <lixm.fnst@cn.fujitsu.com> | 2021-01-14 02:02:58 +0000 |
commit | e863ff24df3332c57030366bb505189a28edf1ea (patch) | |
tree | 96c2cbfe8e9db43c630dc408bd04b2f5b471d0d0 /test/agl-service-network-ctl.c | |
parent | 8c6e15356eaa9b13ff76873e79362ad78c730ec5 (diff) |
Fix potential memory leakneedlefish_13.93.0needlefish/13.93.0marlin_12.93.0marlin_12.92.0marlin_12.91.0marlin_12.90.1marlin_12.90.0marlin/12.93.0marlin/12.92.0marlin/12.91.0marlin/12.90.1marlin/12.90.0lamprey_11.92.0lamprey_11.91.0lamprey/11.92.0lamprey/11.91.0koi_10.93.0koi_10.92.0koi/10.93.0koi/10.92.013.93.012.93.012.92.012.91.012.90.112.90.011.92.011.91.010.93.010.92.0
It is better to init jresp as NULL, and allocate new memory when it is
used, this will avoid the memory leak if the function return during the
process.
jobj should be freed before function returns.
Bug-AGL: SPEC-3584
Change-Id: I4b917f7ecd06a1800d453ec43ffeccee89d923c6
Signed-off-by: Li Xiaoming <lixm.fnst@cn.fujitsu.com>
Diffstat (limited to 'test/agl-service-network-ctl.c')
-rw-r--r-- | test/agl-service-network-ctl.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/test/agl-service-network-ctl.c b/test/agl-service-network-ctl.c index 6808b8d..4be427a 100644 --- a/test/agl-service-network-ctl.c +++ b/test/agl-service-network-ctl.c @@ -405,11 +405,13 @@ bool add_property_value(json_object *jparent, const char *key, int argc, char *a span = next_span(i + 1, argc, argv); if (span < 0) { + json_object_put(jobj); fprintf(stderr, "bad nesting\n"); return NULL; } if (!add_property_value(jobj, key2, span, argv + i + 1)) { + json_object_put(jobj); fprintf(stderr, "error adding object\n"); return false; } |