[FFmpeg-cvslog] libxvid: Check return value of write() call

Diego Biurrun git at videolan.org
Fri Mar 31 22:17:00 EEST 2017


ffmpeg | branch: master | Diego Biurrun <diego at biurrun.de> | Tue Dec  8 10:22:15 2015 +0100| [f7d183f08472e566a2e6b62a80e200a12670ed0e] | committer: Diego Biurrun

libxvid: Check return value of write() call

libavcodec/libxvid_rc.c:106:9: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f7d183f08472e566a2e6b62a80e200a12670ed0e
---

 libavcodec/libxvid_rc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libxvid_rc.c b/libavcodec/libxvid_rc.c
index eddbbe8..94301a2 100644
--- a/libavcodec/libxvid_rc.c
+++ b/libavcodec/libxvid_rc.c
@@ -87,7 +87,10 @@ av_cold int ff_xvid_rate_control_init(MpegEncContext *s)
                  (rce->i_tex_bits + rce->p_tex_bits + rce->misc_bits + 7) / 8,
                  (rce->header_bits + rce->mv_bits + 7) / 8);
 
-        write(fd, tmp, strlen(tmp));
+        if (strlen(tmp) > write(fd, tmp, strlen(tmp))) {
+            av_log(s, AV_LOG_ERROR, "Cannot write to temporary pass2 file.\n");
+            return AVERROR(EIO);
+        }
     }
 
     close(fd);



More information about the ffmpeg-cvslog mailing list