diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2022-08-06 12:16:33 -0300 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2022-08-06 12:16:33 -0300 |
commit | 32329a4084df0a12ff0e4b3853859c778a902468 (patch) | |
tree | 861fa01a6c8c2056173a13f96ef4ff7af7474026 | |
parent | fbe98f57dc779069bd283ac1773866ce73727ea0 (diff) |
keyword: Check validity of keyword value in `create_key_value_file()`
This needs to be done, in case we get a string that's `NULL`.
-rw-r--r-- | keyword.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -234,7 +234,8 @@ char *create_key_value_file(void *data, void *ctx, const keyword **keywords, con for (int i = 0; keywords[i] != NULL; ++i) { int error; keyword_val val = get_keyword(keywords[i], data, ctx, &error); - if (!error || error < 0) { + const int is_valid = keywords[i]->type != TYPE_STRING || (keywords[i]->type == TYPE_STRING && !is_empty(val.str)); + if ((!error || error < 0) && is_valid) { char *key_value = create_key_value_str(keywords[i], val, start_delm, end_delm); buf_len += strlen(key_value); key_values = add_node(&key_values, key_value); |