Re: [PATCH 12/15] scalar: handle NULL value for scalar.repo
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Nov 9, 2026, 13:32 UTC
- Message-ID
- <a595120a-c0d1-4618-b180-886d96aded8b@gmail.com>
- In-Reply-To
- <b4bcaf19ecbf0fc0e165f098c00dccf42985fdd9.1794040968.git.gitgitgadget@gmail.com>
On 11/7/2026 3:42 AM, Thomas Bachem via GitGitGadget wrote:
Show 9 quoted lines
> From: Thomas Bachem <mail@thomasbachem.com> > > A scalar.repo without a value makes "scalar reconfigure --all" > segfault: get_scalar_repos() passes the NULL value to > string_list_append(), which copies it with xstrdup(). > > Reject a missing value with config_error_nonbool(). This cannot break > a working setup, as "scalar register" always writes scalar.repo with > a path.
Show 6 quoted lines
> - if (!strcmp(key, "scalar.repo"))
> + if (!strcmp(key, "scalar.repo")) {
> + if (!value)
> + return config_error_nonbool(key);
> string_list_append(list, value);
> + }I had to look up the definition of 'config_error_nonbool' to be sure that this was the right method to call, but it is:
/*
* Call this to report error for your variable that should not
* get a boolean value (i.e. "[my] var" means "true").
*/
#undef config_error_nonbool
int config_error_nonbool(const char *var)
{
return error(_("missing value for '%s'"), var);
}> +test_expect_success '`reconfigure -a` rejects scalar.repo without a value' ' > + test_must_fail scalar -c scalar.repo reconfigure -a 2>err && > + test_grep "missing value for .scalar.repo." err > +'
Thank you for testing.
-Stolee