From b53ea2b246b4e7536689d2f2ff41b536c340a965 Mon Sep 17 00:00:00 2001 From: Jon Ashburn Date: Thu, 27 Aug 2015 08:30:50 -0600 Subject: loader: Fix SegFault if ICD JSON file doesn't exist to return gracefully --- loader/loader.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'loader') diff --git a/loader/loader.c b/loader/loader.c index c612c769..87e854d3 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -1203,6 +1203,10 @@ static cJSON *loader_get_json(const char *filename) cJSON *json; uint64_t len; file = fopen(filename,"rb"); + if (!file) { + loader_log(VK_DBG_REPORT_ERROR_BIT, 0, "Couldn't open JSON file %s", filename); + return NULL; + } fseek(file, 0, SEEK_END); len = ftell(file); fseek(file, 0, SEEK_SET); @@ -1682,6 +1686,8 @@ void loader_icd_scan(struct loader_icd_libs *icds) cJSON *json; json = loader_get_json(file_str); + if (!json) + continue; cJSON *item; item = cJSON_GetObjectItem(json, "file_format_version"); if (item == NULL) -- cgit v1.2.3