From 9d825963310c744e8bd2c8ca03b7cdc99aae898e Mon Sep 17 00:00:00 2001
From: "Timothy B. Terriberry" <tterribe@xiph.org>
Date: Wed, 9 Jan 2013 18:56:57 -0800
Subject: [PATCH] Make opusfile_example fwrites all-or-nothing.

This makes it more likely the WAV file header matches the amount of
 data actually written if we run out of space.
This is easier than making the accounting better.
---
 examples/opusfile_example.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/opusfile_example.c b/examples/opusfile_example.c
index bb15f14..22a13d6 100644
--- a/examples/opusfile_example.c
+++ b/examples/opusfile_example.c
@@ -301,7 +301,7 @@ int main(int _argc,const char **_argv){
         out[2*si+0]=(unsigned char)(pcm[si]&0xFF);
         out[2*si+1]=(unsigned char)(pcm[si]>>8&0xFF);
       }
-      if(!fwrite(out,sizeof(*out)*4,ret,stdout)){
+      if(!fwrite(out,sizeof(*out)*4*ret,1,stdout)){
         fprintf(stderr,"\nError writing decoded audio data: %s\n",
          strerror(errno));
         ret=EXIT_FAILURE;
-- 
GitLab