git/compat
Johannes Schindelin 3057da5ad5 winansi: avoid use of uninitialized value
To initialize the foreground color attributes of "plain text", our ANSI
emulation tries to infer them from the currently attached console while
running the is_console() function. This function first tries to detect any
console attached to stdout, then it is called with stderr.

If neither stdout nor stderr has any console attached, it does not
actually matter what we use for "plain text" attributes, as we never need
to output any text to any console in that case.

However, after working on stdout and stderr, is_console() is called with
stdin, and it still tries to initialize the "plain text" attributes if
they had not been initialized earlier. In this case, we cannot detect any
attributes, and we used an uninitialized value for them.

Naturally, Coverity complained about this use case because it could not
reason about the code deeply enough to figure out that we do not even use
those attributes in that case.

Let's just initialize the value to 0 in that case, both to avoid future
Coverity reports, and to help catch future regressions in case anybody
changes the order of the is_console() calls (which would make the text
black on black).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-08 12:18:19 +09:00
..
nedmalloc compat: move strdup(3) replacement to its own file 2016-09-07 10:41:45 -07:00
poll mingw: avoid warnings when casting HANDLEs to int 2016-01-15 14:01:52 -08:00
regex regex: fix a SIZE_MAX macro redefinition warning 2016-06-06 19:22:00 -07:00
vcbuild MSVC: use shipped headers instead of fallback definitions 2016-03-30 11:16:20 -07:00
win32 Merge branch 'jk/push-client-deadlock-fix' 2016-05-18 15:11:46 -07:00
apple-common-crypto.h imap-send: use HMAC() function provided by OpenSSL 2016-04-08 11:45:47 -07:00
basename.c compat/basename.c: provide a dirname() compatibility function 2016-01-12 10:40:54 -08:00
bswap.h bswap: add NO_UNALIGNED_LOADS define 2016-01-04 09:51:33 -08:00
fopen.c compat/fopen.c: avoid clobbering the system defined fopen macro 2008-05-08 17:43:01 -07:00
gmtime.c date: recognize bogus FreeBSD gmtime output 2014-04-01 14:39:04 -07:00
hstrerror.c compat/hstrerror: convert sprintf to snprintf 2015-09-25 10:18:18 -07:00
inet_ntop.c compat/inet_ntop: fix off-by-one in inet_ntop4 2015-09-25 10:18:18 -07:00
inet_pton.c Drop system includes from inet_pton/inet_ntop compatibility wrappers 2012-02-05 16:32:33 -08:00
memmem.c optimize compat/ memmem() 2009-03-02 18:28:06 -08:00
mingw.c mingw: avoid memory leak when splitting PATH 2017-05-08 12:18:19 +09:00
mingw.h mingw: intercept isatty() to handle /dev/null as Git expects it 2016-12-11 16:15:46 -08:00
mkdir.c compat: some mkdir() do not like a slash at the end 2012-08-24 09:48:51 -07:00
mkdtemp.c Fix gitmkdtemp: correct test for mktemp() return value 2010-02-25 12:08:22 -08:00
mmap.c wrapper.c: add xpread() similar to xread() 2014-04-10 12:18:55 -07:00
msvc.c win32: use our own dirent.h 2010-11-23 16:06:50 -08:00
msvc.h MSVC: fix stat definition hell 2013-09-11 11:08:52 -07:00
obstack.c obstack.c: Fix some sparse warnings 2011-09-11 14:43:33 -07:00
obstack.h obstack: fix spelling of similar 2013-04-12 12:23:20 -07:00
pread.c Replacing the system call pread() with lseek()/xread()/lseek() sequence. 2007-01-09 16:40:40 -08:00
precompose_utf8.c typofix: assorted typofixes in comments, documentation and messages 2016-05-06 13:16:37 -07:00
precompose_utf8.h probe_utf8_pathname_composition: use internal strbuf 2015-10-05 11:06:49 -07:00
qsort.c use st_add and st_mult for allocation size computation 2016-02-22 14:51:09 -08:00
qsort_s.c compat: add qsort_s() 2017-01-23 11:02:34 -08:00
setenv.c use st_add and st_mult for allocation size computation 2016-02-22 14:51:09 -08:00
sha1-chunked.c sha1: allow limiting the size of the data passed to SHA1_Update() 2015-11-05 10:35:11 -08:00
sha1-chunked.h sha1: allow limiting the size of the data passed to SHA1_Update() 2015-11-05 10:35:11 -08:00
snprintf.c MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more 2016-03-30 11:13:01 -07:00
stat.c compat: convert modes to use portable file type values 2014-12-04 11:58:36 -08:00
strcasestr.c Clean up compatibility definitions. 2005-12-05 15:50:29 -08:00
strdup.c compat: move strdup(3) replacement to its own file 2016-09-07 10:41:45 -07:00
strlcpy.c simplify inclusion of system header files. 2006-12-20 09:51:35 -08:00
strtoimax.c Add strtoimax() compatibility function. 2011-11-02 13:06:30 -07:00
strtoumax.c Add a compat/strtoumax.c for Solaris 8. 2007-02-19 18:20:30 -08:00
terminal.c strbuf: introduce strbuf_getline_{lf,nul}() 2016-01-15 10:12:51 -08:00
terminal.h add generic terminal prompt function 2011-12-12 16:09:38 -08:00
unsetenv.c Revert "compat/unsetenv.c: Fix a sparse warning" 2013-07-21 15:09:56 -07:00
win32.h mingw: rename WIN32 cpp macro to GIT_WINDOWS_NATIVE 2013-05-08 12:14:35 -07:00
win32mmap.c mmap(win32): avoid expensive fstat() call 2016-04-22 15:01:16 -07:00
winansi.c winansi: avoid use of uninitialized value 2017-05-08 12:18:19 +09:00