Commit 9443151d authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

src/flac/utils.c : Make sure get_console_width() returns value > 0.

Previous version of get_console_width() may return 0 which will result in
a division by 0 in stats_print_name():

	console_width = get_console_width();
	len = strlen_console(name)+2;
	console_chars_left = console_width  - (len % console_width);

Bug-report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=739613
Patch-from: lvqcl <lvqcl.mail@gmail.com>
parent d043785d
......@@ -176,7 +176,7 @@ static int console_chars_left;
int get_console_width(void)
{
int width = 80;
int width = 0;
#if defined _WIN32
width = win_get_console_width();
#elif defined __EMX__
......@@ -185,8 +185,11 @@ int get_console_width(void)
width = s[0];
#elif defined GWINSZ_IN_SYS_IOCTL
struct winsize w;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1) width = w.ws_col;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1)
width = w.ws_col;
#endif
if (width <= 0)
width = 80;
return width;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment