Merge branch 'sb/config-write-fix'
[gitweb.git] / color.c
diff --git a/color.c b/color.c
index c6c6c4f580fe9bde55bd5f433b1bffd3932053f8..ebb222ec3323d45bdcd298208903dff9a90d5c3f 100644 (file)
--- a/color.c
+++ b/color.c
@@ -174,7 +174,7 @@ static char *color_output(char *out, int len, const struct color *c, char type)
                break;
        case COLOR_ANSI:
                if (len < 2)
-                       die("BUG: color parsing ran out of space");
+                       BUG("color parsing ran out of space");
                *out++ = type;
                *out++ = '0' + c->value;
                break;
@@ -256,7 +256,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)
 #undef OUT
 #define OUT(x) do { \
        if (dst == end) \
-               die("BUG: color parsing ran out of space"); \
+               BUG("color parsing ran out of space"); \
        *dst++ = (x); \
 } while(0)
 
@@ -343,6 +343,9 @@ int want_color_fd(int fd, int var)
 
        static int want_auto[3] = { -1, -1, -1 };
 
+       if (fd < 1 || fd >= ARRAY_SIZE(want_auto))
+               BUG("file descriptor out of range: %d", fd);
+
        if (var < 0)
                var = git_use_color_default;