From 2f017c4ba7264abe6afff49436a5d289df6c0dc3 Mon Sep 17 00:00:00 2001 From: roblabla Date: Tue, 30 Oct 2018 16:34:56 +0000 Subject: [PATCH] Allow service_host and service_access to be NULL. Fixes compatibility with old-style JSON, and is more flexible anyways. --- src/npdmtool.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/npdmtool.c b/src/npdmtool.c index 25148c1..a953cc5 100644 --- a/src/npdmtool.c +++ b/src/npdmtool.c @@ -387,7 +387,7 @@ int CreateNpdm(const char *json, void **dst, u32 *dst_size) { u32 sac_size = 0; services = cJSON_GetObjectItemCaseSensitive(npdm_json, "service_host"); - if (!cJSON_IsArray(services)) { + if (services != NULL && !cJSON_IsArray(services)) { fprintf(stderr, "Service Host must be an array!\n"); status = 0; goto NPDM_BUILD_END; @@ -420,14 +420,14 @@ int CreateNpdm(const char *json, void **dst, u32 *dst_size) { } services = cJSON_GetObjectItemCaseSensitive(npdm_json, "service_access"); - if (!(cJSON_IsObject(services) || cJSON_IsArray(services))) { + if (!(services == NULL || cJSON_IsObject(services) || cJSON_IsArray(services))) { fprintf(stderr, "Service Access must be an array!\n"); status = 0; goto NPDM_BUILD_END; } int sac_obj = 0; - if (cJSON_IsObject(services)) { + if (services != NULL && cJSON_IsObject(services)) { sac_obj = 1; fprintf(stderr, "Using deprecated service_access format. Please turn it into an array.\n"); }