Skip to content

Commit 89086c9

Browse files
peffgitster
authored andcommitted
help: handle NULL value for alias.* config
When showing all config with "git help --all", we print the list of defined aliases. But our config callback to do so does not check for a NULL value, meaning a config block like: [alias] foo will cause us to segfault. We should detect and complain about this in the usual way. Since this command is purely informational (and we aren't trying to run the alias), we could perhaps just generate a warning and continue. But this sort of misconfiguration should be pretty rare, and the error message we will produce points directly to the line of config that needs to be fixed. So just generating the usual error should be OK. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 24942ef commit 89086c9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

help.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,11 @@ static int get_alias(const char *var, const char *value,
464464
{
465465
struct string_list *list = data;
466466

467-
if (skip_prefix(var, "alias.", &var))
467+
if (skip_prefix(var, "alias.", &var)) {
468+
if (!value)
469+
return config_error_nonbool(var);
468470
string_list_append(list, var)->util = xstrdup(value);
471+
}
469472

470473
return 0;
471474
}

0 commit comments

Comments
 (0)