From e8e79b7a2b88262b84bf6006bc7cd5764962fdc9 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 30 Mar 2022 14:06:23 -0700 Subject: til_settings: fix empty values in til_settings_new() Previously if you supplied an empty setting value like so: "--module=compose,layers=" The interactive setup would get itself into an infinite loop because the layers setting is already present, but has a NULL value. This wasn't a NULL value, it was a "" value. The parser should just fallthrough to the value state from the equal state after recording the value's start pointer. This will result in a "" value getting allocated and assigned to the value before the loop breaks out on the '\0' immediately following the '='. There are probably other edge cases which need better handling here. --- src/til_settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/til_settings.c b/src/til_settings.c index 5d890d4..8aa172b 100644 --- a/src/til_settings.c +++ b/src/til_settings.c @@ -96,7 +96,7 @@ til_settings_t * til_settings_new(const char *settings_string) case TIL_SETTINGS_FSM_STATE_EQUAL: token = p; state = TIL_SETTINGS_FSM_STATE_VALUE; - break; + /* fallthrough, necessary to not leave NULL values for empty "key=\0" settings */ case TIL_SETTINGS_FSM_STATE_VALUE: if (*p == ',' || *p == '\0') { -- cgit v1.2.3