summaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal-composer-binding.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-08-23 16:25:50 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-08-23 17:32:00 +0200
commitfbdf29b8af47f567f472a459842d262e8abf5b9c (patch)
tree7f56f958a7c05ff60f4172cc39107b86327cae70 /signal-composer-binding/signal-composer-binding.cpp
parent3d09d0c91fa1fa5d66ba48cbfefe10ec7b9ac3ad (diff)
Fix: segfault at object addition
JSON object release is done by the appfw so no need to release the object in the request. Tiny typo about the filepath in testsuite. Change-Id: I8347adafbb5fa8e9e3b89c2e6db74c37f4910adf Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal-composer-binding.cpp')
-rw-r--r--signal-composer-binding/signal-composer-binding.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/signal-composer-binding/signal-composer-binding.cpp b/signal-composer-binding/signal-composer-binding.cpp
index a9be63e..234888c 100644
--- a/signal-composer-binding/signal-composer-binding.cpp
+++ b/signal-composer-binding/signal-composer-binding.cpp
@@ -181,9 +181,17 @@ void addObjects(afb_req request)
if(!objectsJ)
{
json_object* responseJ = ScanForConfig(CONTROL_CONFIG_PATH, CTL_SCAN_RECURSIVE, filepath, ".json");
- filepath = ConfigSearch(nullptr, responseJ);
- if(filepath)
- {objectsJ = json_object_from_file(filepath);}
+ if(responseJ)
+ {
+ filepath = ConfigSearch(nullptr, responseJ);
+ if(filepath)
+ {objectsJ = json_object_from_file(filepath);}
+ }
+ else
+ {
+ afb_req_fail_f(request, "Fail to find file: %s", filepath);
+ return;
+ }
}
}
else
@@ -194,10 +202,9 @@ void addObjects(afb_req request)
json_object_object_get_ex(objectsJ, "sources", &sourcesJ);
json_object_object_get_ex(objectsJ, "signals", &signalsJ);
- if( sourcesJ && composer.loadSources(sourcesJ))
+ if(sourcesJ && composer.loadSources(sourcesJ))
{
afb_req_fail_f(request, "Loading 'sources' configuration or subscription error", "Error code: -2");
- json_object_put(objectsJ);
return;
}
if(signalsJ)
@@ -207,7 +214,6 @@ void addObjects(afb_req request)
else
{
afb_req_fail_f(request, "Loading 'signals' configuration or subscription error", "Error code: -2");
- json_object_put(objectsJ);
return;
}
}