diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2018-09-07 13:49:54 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2018-09-07 13:49:54 +0200 |
commit | d83404e41808421442c8257392ecd095042cbfbf (patch) | |
tree | 28d884caa1c8341ce19ff64748ef5e35f518f3f5 | |
parent | 7a720bfe087a5301e27a40ca8a3b687077541fa8 (diff) | |
download | newlib-d83404e41808421442c8257392ecd095042cbfbf.zip newlib-d83404e41808421442c8257392ecd095042cbfbf.tar.gz newlib-d83404e41808421442c8257392ecd095042cbfbf.tar.bz2 |
Cygwin: console: make sure EnumFontFamiliesExW loop isn't infinite
The current loop condition is borderline. Make sure it ends and
choose a replacement char in the unlikely case the current console
font isn't recognized at all.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/fhandler_console.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index ce6de6f..6a0d640 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -2016,10 +2016,16 @@ check_font (HANDLE hdl) do { EnumFontFamiliesExW (cdc, &lf, enum_proc, (LPARAM) &done, 0); - if (!done && cp > lf.lfFaceName) + if (!done) *cp-- = L'\0'; } - while (!done); + while (!done && cp >= lf.lfFaceName); + /* What, really? No recognizable font? */ + if (!done) + { + rp_char = L'?'; + return; + } /* Yes. Check for the best replacement char. */ HFONT f = CreateFontW (0, 0, 0, 0, cfi.FontWeight, FALSE, FALSE, FALSE, |