diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-03-30 14:06:23 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-03-30 14:06:23 -0700 |
commit | e8e79b7a2b88262b84bf6006bc7cd5764962fdc9 (patch) | |
tree | ae64007c14fb96af0f3a6366b0a84b530ad79d3e | |
parent | f3290897544c4427dc208d1dd1e33836639be8ba (diff) |
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.
-rw-r--r-- | src/til_settings.c | 2 |
1 files changed, 1 insertions, 1 deletions
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') { |