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>
This commit is contained in:
parent
7127954aaa
commit
90e0fea6c6
1 changed files with 3 additions and 0 deletions
|
@ -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");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue