diff --git a/CHANGELOG.md b/CHANGELOG.md index c94058a..73d0100 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,12 @@ ### Deprecated ### Removed ### Fixed + +* Compiler error _‘fmt’ may be used uninitialized_ ([#311][311]). + +[311]: https://codeberg.org/dnkl/yambar/issues/311 + + ### Security ### Contributors diff --git a/tag.c b/tag.c index b098eb7..0f44d7e 100644 --- a/tag.c +++ b/tag.c @@ -674,7 +674,7 @@ tags_expand_template(const char *template, const struct tag_set *tags) const long max = tag->max(tag); long value = kind == VALUE_MIN ? min : max; - const char *fmt; + const char *fmt = NULL; switch (format) { case FMT_DEFAULT: fmt = zero_pad ? "%0*ld" : "%*ld"; break; case FMT_HEX: fmt = zero_pad ? "%0*lx" : "%*lx"; break; @@ -704,6 +704,8 @@ tags_expand_template(const char *template, const struct tag_set *tags) } } + assert(fmt != NULL); + char str[24]; snprintf(str, sizeof(str), fmt, digits, value); sbuf_append(&formatted, str);