libxvid: Check return value of write() call
authorDiego Biurrun <diego@biurrun.de>
Tue, 8 Dec 2015 09:22:15 +0000 (10:22 +0100)
committerDiego Biurrun <diego@biurrun.de>
Fri, 11 Nov 2016 09:17:07 +0000 (10:17 +0100)
libavcodec/libxvid_rc.c:106:9: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]

libavcodec/libxvid_rc.c

index eddbbe8..94301a2 100644 (file)
@@ -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);