Commit c56e9e05 authored by Ramiro Polla's avatar Ramiro Polla

Open 2-pass logfile in binary mode for both reading and writing.

This fixes a regression on Windows introduced by r22769 in which the data read
from the file was not properly zero terminated. The file was read as text,
which caused the \r characters to be suppressed. Since the zero termination
happens at the end of the buffer, and there was one byte less read per line,
this caused the remaining space on the buffer to contain random data.

Originally committed as revision 23251 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 80b39e1c
...@@ -641,7 +641,7 @@ int read_yesno(void) ...@@ -641,7 +641,7 @@ int read_yesno(void)
int read_file(const char *filename, char **bufptr, size_t *size) int read_file(const char *filename, char **bufptr, size_t *size)
{ {
FILE *f = fopen(filename, "r"); FILE *f = fopen(filename, "rb");
if (!f) { if (!f) {
fprintf(stderr, "Cannot read file '%s': %s\n", filename, strerror(errno)); fprintf(stderr, "Cannot read file '%s': %s\n", filename, strerror(errno));
......
...@@ -2291,7 +2291,7 @@ static int av_transcode(AVFormatContext **output_files, ...@@ -2291,7 +2291,7 @@ static int av_transcode(AVFormatContext **output_files,
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
i); i);
if (codec->flags & CODEC_FLAG_PASS1) { if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "w"); f = fopen(logfilename, "wb");
if (!f) { if (!f) {
fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno)); fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno));
av_exit(1); av_exit(1);
......
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