[FFmpeg-devel] [PATCH] xvid_rc: check that write() succeeded.

Paul B Mahol onemda at gmail.com
Sat Feb 4 02:47:19 CET 2012


On 2/4/12, Michael Niedermayer <michaelni at gmx.at> wrote:
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
>  libavcodec/libxvid_rc.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/libavcodec/libxvid_rc.c b/libavcodec/libxvid_rc.c
> index 10a7c1c..10d6d0a 100644
> --- a/libavcodec/libxvid_rc.c
> +++ b/libavcodec/libxvid_rc.c
> @@ -59,7 +59,10 @@ int ff_xvid_rate_control_init(MpegEncContext *s){
>              rce->skip_count, (rce->i_tex_bits + rce->p_tex_bits +
> rce->misc_bits+7)/8, (rce->header_bits+rce->mv_bits+7)/8);
>
>  //av_log(NULL, AV_LOG_ERROR, "%s\n", tmp);
> -        write(fd, tmp, strlen(tmp));
> +        if (write(fd, tmp, strlen(tmp)) == -1) {

write can return other values, so better check for anything < 0
and return/report such value.
> +            av_log(NULL, AV_LOG_ERROR, "Error writing 2pass logfile\n");
> +            return -1;
> +        }
>      }
>
>      close(fd);


More information about the ffmpeg-devel mailing list