From 4206ac6bbffb8c3626863ec16654231a298c6d3c Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 29 Aug 2014 19:11:41 -0700 Subject: [PATCH] webpmux: (windows) open stdout in binary mode prevents corrupt output. related to issue #217 (cherry picked from commit e80eab1fbc63fa267f7e97a89c6d5d07b9981d45) Change-Id: I6f0dac8131127717ba72b0709fb35d421ab41acb --- examples/webpmux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/webpmux.c b/examples/webpmux.c index f314cef8..8899ed8d 100644 --- a/examples/webpmux.c +++ b/examples/webpmux.c @@ -402,8 +402,9 @@ static int CreateMux(const char* const filename, WebPMux** mux) { static int WriteData(const char* filename, const WebPData* const webpdata) { int ok = 0; - FILE* fout = strcmp(filename, "-") ? fopen(filename, "wb") : stdout; - if (!fout) { + FILE* fout = strcmp(filename, "-") ? fopen(filename, "wb") + : ExUtilSetBinaryMode(stdout); + if (fout == NULL) { fprintf(stderr, "Error opening output WebP file %s!\n", filename); return 0; }