Browse Source

color.c: fix color_parse_mem() with value_len == 0

In this code we want to match the word "reset". If len is zero,
strncasecmp() will return zero and we incorrectly assume it's "reset" as
a result.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Nguyễn Thái Ngọc Duy 8 years ago committed by Junio C Hamano
parent
commit
c2f41bf521
  1. 3
      color.c

3
color.c

@ -207,6 +207,9 @@ int color_parse_mem(const char *value, int value_len, char *dst) @@ -207,6 +207,9 @@ int color_parse_mem(const char *value, int value_len, char *dst)
struct color fg = { COLOR_UNSPECIFIED };
struct color bg = { COLOR_UNSPECIFIED };

if (!len)
return -1;

if (!strncasecmp(value, "reset", len)) {
xsnprintf(dst, end - dst, GIT_COLOR_RESET);
return 0;

Loading…
Cancel
Save