From 86b77f39ed7e8ae536e416e2e4f2d361a365ccf6 Mon Sep 17 00:00:00 2001 From: Ludovico de Nittis <ludovico.denittis@collabora.com> Date: Fri, 10 Apr 2020 20:33:36 +0200 Subject: [PATCH] graphics.c: Check for empty json file If we have an empty json file `json_node_get_object` will fail. Add a check before it and return with SRT_GRAPHICS_ISSUES_CANNOT_LOAD Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com> --- steam-runtime-tools/graphics.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/steam-runtime-tools/graphics.c b/steam-runtime-tools/graphics.c index f06d36833..e4ffc4a78 100644 --- a/steam-runtime-tools/graphics.c +++ b/steam-runtime-tools/graphics.c @@ -357,6 +357,14 @@ _srt_process_wflinfo (JsonParser *parser, const gchar **version_string, const gc SrtGraphicsIssues issues = SRT_GRAPHICS_ISSUES_NONE; JsonNode *node = json_parser_get_root (parser); + + if (node == NULL) + { + g_debug ("The json output is empty"); + issues |= SRT_GRAPHICS_ISSUES_CANNOT_LOAD; + return issues; + } + JsonObject *object = json_node_get_object (node); JsonNode *sub_node = NULL; JsonObject *sub_object = NULL; @@ -405,6 +413,14 @@ _srt_process_vulkaninfo (JsonParser *parser, gchar **new_version_string, const g SrtGraphicsIssues issues = SRT_GRAPHICS_ISSUES_NONE; JsonNode *node = json_parser_get_root (parser); + + if (node == NULL) + { + g_debug ("The json output is empty"); + issues |= SRT_GRAPHICS_ISSUES_CANNOT_LOAD; + return issues; + } + JsonObject *object = json_node_get_object (node); JsonNode *sub_node = NULL; JsonObject *sub_object = NULL; -- GitLab