brewery
notashelf /
b36d490de55646507f200ee2e3a71164c79c4c67

chroma

public

Lightweight wallpaper daemon for Wayland

Star0tarball
clone
ssh://git@git.notashelf.dev:33/notashelf/chroma.git

Commit b36d490de556

tarball

NotAShelf <raf@notashelf.dev> · 2026-05-17 21:23 UTC

unverified1 files changed+10-8
config: add cleanup and warnings for config parsing edge cases

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ifd08f33a0e6cc6e4f49966ea1c3f03f56a6a6964
diff --git a/src/config.c b/src/config.cindex d082249..c308904 100644--- a/src/config.c+++ b/src/config.c@@ -232,6 +232,7 @@ int chroma_config_load_toml(chroma_config_t *config, const char *config_file) {   toml_result_t result = toml_parse_file_ex(config_file);   if (!result.ok) {     chroma_log("DEBUG", "TOML parse failed: %s", result.errmsg);+    toml_free(result);     return CHROMA_ERROR_CONFIG;   } @@ -244,6 +245,12 @@ int chroma_config_load_toml(chroma_config_t *config, const char *config_file) {     const char *path_to_use = expanded_path ? expanded_path : default_image.u.s;     if (strlen(path_to_use) < sizeof(config->default_image)) {       strcpy(config->default_image, path_to_use);+    } else {+      chroma_log(+          "WARN", "default_image path too long (%zu >= %zu), truncating: %s",+          strlen(path_to_use), sizeof(config->default_image), path_to_use);+      snprintf(config->default_image, sizeof(config->default_image), "%s",+               path_to_use);     }     if (expanded_path) {       free(expanded_path);@@ -427,14 +434,9 @@ static void init_default_config(chroma_config_t *config) {   config->max_output_height = 2160;   // 4K height   config->min_scale_factor = 0.25f;   // don't scale below 25% -  // Set default image path (can be overridden)-  const char *home = getenv("HOME");-  if (home) {-    snprintf(config->default_image, sizeof(config->default_image),-             "%s/.config/chroma/default.jpg", home);-  } else {-    strcpy(config->default_image, "/usr/share/pixmaps/chroma-default.jpg");-  }+  // Leave default_image empty - user must configure it explicitly+  // This avoids errors when the hardcoded path doesn't exist+  config->default_image[0] = '\0'; }  // Load configuration from file (TOML format only)