mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-15 03:20:00 +01:00
ffmpeg: check tcgetattr result.
This fixes parallel FATE (make fate -j4) failing under valgrind with:
Syscall param ioctl(TCSET{S,SW,SF}) points to uninitialised byte(s)
at 0x5D98B23: tcsetattr (tcsetattr.c:88)
by 0x43D66C: term_init (ffmpeg.c:734)
by 0x43CD8D: main (ffmpeg.c:5071)
Address 0x7fefffdd0 is on thread 1's stack
Uninitialised value was created by a stack allocation
at 0x43D5B0: term_init (ffmpeg.c:716)
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
This commit is contained in:
7
ffmpeg.c
7
ffmpeg.c
@@ -298,6 +298,7 @@ typedef struct OutputStream {
|
|||||||
|
|
||||||
/* init terminal so that we can grab keys */
|
/* init terminal so that we can grab keys */
|
||||||
static struct termios oldtty;
|
static struct termios oldtty;
|
||||||
|
static int restore_tty;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct OutputFile {
|
typedef struct OutputFile {
|
||||||
@@ -696,7 +697,7 @@ static void term_exit(void)
|
|||||||
{
|
{
|
||||||
av_log(NULL, AV_LOG_QUIET, "%s", "");
|
av_log(NULL, AV_LOG_QUIET, "%s", "");
|
||||||
#if HAVE_TERMIOS_H
|
#if HAVE_TERMIOS_H
|
||||||
if(!run_as_daemon)
|
if(restore_tty)
|
||||||
tcsetattr (0, TCSANOW, &oldtty);
|
tcsetattr (0, TCSANOW, &oldtty);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -718,8 +719,9 @@ static void term_init(void)
|
|||||||
if(!run_as_daemon){
|
if(!run_as_daemon){
|
||||||
struct termios tty;
|
struct termios tty;
|
||||||
|
|
||||||
tcgetattr (0, &tty);
|
if (tcgetattr (0, &tty) == 0) {
|
||||||
oldtty = tty;
|
oldtty = tty;
|
||||||
|
restore_tty = 1;
|
||||||
atexit(term_exit);
|
atexit(term_exit);
|
||||||
|
|
||||||
tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
|
tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
|
||||||
@@ -732,6 +734,7 @@ static void term_init(void)
|
|||||||
tty.c_cc[VTIME] = 0;
|
tty.c_cc[VTIME] = 0;
|
||||||
|
|
||||||
tcsetattr (0, TCSANOW, &tty);
|
tcsetattr (0, TCSANOW, &tty);
|
||||||
|
}
|
||||||
signal(SIGQUIT, sigterm_handler); /* Quit (POSIX). */
|
signal(SIGQUIT, sigterm_handler); /* Quit (POSIX). */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user