summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2023-09-14 10:27:56 +0100
committerJacopo Mondi <jacopo.mondi@ideasonboard.com>2023-09-16 17:33:44 +0200
commit90e0fea6c6ba6294bf9438d37d74676cc53ef924 (patch)
tree4e3fedd9b2012b675d8e54113e9bf914c720d8a3 /src
parent7127954aaa5fe9938743cbc41a328027697aba8a (diff)
ipa: rpi: Fix segfault when parsing invalid json file
If the json file parsing failed due to a malformed file, the root pointer would be null. This was not tested and caused a segfault when trying to use the pointer to retrieve the version key. Fix this by bailing out early if the parser returns a null pointer. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/ipa/rpi/controller/controller.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/ipa/rpi/controller/controller.cpp b/src/ipa/rpi/controller/controller.cpp
index fa172113..14d245da 100644
--- a/src/ipa/rpi/controller/controller.cpp
+++ b/src/ipa/rpi/controller/controller.cpp
@@ -56,6 +56,9 @@ int Controller::read(char const *filename)
}
std::unique_ptr<YamlObject> root = YamlParser::parse(file);
+ if (!root)
+ return -EINVAL;
+
double version = (*root)["version"].get<double>(1.0);
target_ = (*root)["target"].get<std::string>("bcm2835");