From 80816b8b63091c7117d17e673a0d58e019224a60 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Thu, 16 Nov 2023 18:02:44 +0200 Subject: [PATCH] config: allow NULL as default in config_get_char --- main/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/config.c b/main/config.c index 55d0212c..baeee5e7 100644 --- a/main/config.c +++ b/main/config.c @@ -81,7 +81,7 @@ char *config_get_char(const char *key, const char *default_value) if (val != NULL && cJSON_IsString(val) && val->valuestring != NULL) { ret = strndup(val->valuestring, strlen(val->valuestring)); } else { - ret = strndup(default_value, strlen(default_value)); + ret = default_value == NULL ? NULL : strndup(default_value, strlen(default_value)); } ESP_LOGD(TAG, "config_get_char(%s): %s", key, ret); return ret;