summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-06-15 21:08:57 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-10-08 15:53:53 +0200
commit8e923d9e07f483d209269d4af9070ed729600f05 (patch)
tree4e37676cbc96893df0473241831bb38024d116c3 /4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
parent5bfa3c8ed61c724388b1b3e802cc8fe97b0709de (diff)
Free json objects that should have been freed
Free json objects that should have been freed after use. Change-Id: Ifb3dab9672d0c039292ae05f23ade008fe82ade8 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
index 07ec9cc..f560c7c 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
@@ -222,7 +222,9 @@ int HalCtlsProcessOneHalMapObject(AFB_ApiT apiHandle, struct CtlHalAlsaMap *alsa
int HalCtlsHandleOneHalMapObject(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaMap *alsaMap)
{
- json_object *valueJ, *convertedValueJ;
+ int err;
+
+ json_object *valueJ, *convertedValueJ = NULL;
if(alsaMap->ctl.alsaCtlCreation) {
if(HalCtlsCreateAlsaCtl(apiHandle, cardId, &alsaMap->ctl)) {
@@ -242,20 +244,28 @@ int HalCtlsHandleOneHalMapObject(AFB_ApiT apiHandle, char *cardId, struct CtlHal
if(alsaMap->ctl.value) {
// TBD JAI : handle alsa controls type
valueJ = json_object_new_int(alsaMap->ctl.value);
+ err = 0;
if(HalCtlsNormalizeJsonValues(apiHandle, &alsaMap->ctl.alsaCtlProperties, valueJ, &convertedValueJ)) {
AFB_ApiError(apiHandle, "Error when trying to convert initiate value json '%s'", json_object_get_string(valueJ));
- return -3;
+ err = -3;
}
-
- if(HalCtlsSetAlsaCtlValue(apiHandle, cardId, alsaMap->ctl.numid, convertedValueJ)) {
+ else if(HalCtlsSetAlsaCtlValue(apiHandle, cardId, alsaMap->ctl.numid, convertedValueJ)) {
AFB_ApiError(apiHandle,
"Error while trying to set initial value on alsa control %i, device '%s', value '%s'",
alsaMap->ctl.numid,
cardId,
json_object_get_string(valueJ));
- return -4;
+ err = -4;
}
+
+ json_object_put(valueJ);
+
+ if(convertedValueJ)
+ json_object_put(convertedValueJ);
+
+ if(err)
+ return err;
}
if(alsaMap->actionJ) {
@@ -390,7 +400,7 @@ void HalCtlsActionOnCall(AFB_ReqT request)
struct SpecificHalData *currentCtlHalData;
struct CtlHalMixerData *currentMixerData;
- json_object *requestJson, *returnJ, *toReturnJ;
+ json_object *requestJson, *returnJ = NULL, *toReturnJ;
apiHandle = (AFB_ApiT) afb_request_get_dynapi(request);
if(! apiHandle) {
@@ -443,7 +453,7 @@ void HalCtlsActionOnCall(AFB_ReqT request)
}
else if(wrap_json_unpack(returnJ, "{s:o}", "response", &toReturnJ)) {
AFB_ReqSuccessF(request,
- returnJ,
+ json_object_get(returnJ),
"%s: Seems that %s call to api %s succeed, but no response was found : '%s'",
__func__,
currentMixerData->verbToCall,
@@ -452,11 +462,14 @@ void HalCtlsActionOnCall(AFB_ReqT request)
}
else {
AFB_ReqSuccessF(request,
- toReturnJ,
+ json_object_get(toReturnJ),
"Action %s correctly transferred to %s without any error raised",
currentMixerData->verbToCall,
apiToCall);
}
+
+ if(returnJ)
+ json_object_put(returnJ);
}
json_object *HalCtlsGetJsonArrayForMixerDataTable(AFB_ApiT apiHandle, struct CtlHalMixerDataT *currentMixerDataT, enum MixerDataType dataType)