From 4f650f1d88ef43c4befc2b035275f294a3c2d43f Mon Sep 17 00:00:00 2001 From: "Li, Xiaoming" Date: Wed, 13 Jan 2021 15:27:09 +0800 Subject: Fix potential memory leak In some cases, j_query or j_array maybe unfreed after return; Bug-AGL: SPEC-3584 Change-Id: I4bb7ff5eb51aa77d4419440701faaab8c26bc8cf Signed-off-by: Li, Xiaoming --- binding/wrap-unicens/wrap-unicens.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/binding/wrap-unicens/wrap-unicens.c b/binding/wrap-unicens/wrap-unicens.c index 84b94cd..e27d999 100644 --- a/binding/wrap-unicens/wrap-unicens.c +++ b/binding/wrap-unicens/wrap-unicens.c @@ -154,6 +154,10 @@ extern int wrap_ucs_i2cwrite_sync(uint16_t node, uint8_t *data_ptr, uint8_t data j_array = json_object_new_array(); if(! j_query || ! j_array) { + if (j_query) + json_object_put(j_query); + if (j_array) + json_object_put(j_array); AFB_API_ERROR(api_handle_, "Failed to create writei2c json objects"); return -1; } -- cgit 1.2.3-korg