mirror of
https://github.com/mpv-player/mpv
synced 2025-01-19 13:51:14 +00:00
video/image_writer: check for write errors
make sure that fwrite is error checked. and if any data was still remaining on the buffer, it will be flushed - and errors checked - via the fclose() call below.
This commit is contained in:
parent
6b76000f0b
commit
dc06dec1ee
@ -127,7 +127,7 @@ static enum AVPixelFormat replace_j_format(enum AVPixelFormat fmt)
|
||||
|
||||
static bool write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, const char *filename)
|
||||
{
|
||||
FILE* fp = fopen(filename, "wb");
|
||||
FILE *fp = fopen(filename, "wb");
|
||||
if (!fp) {
|
||||
MP_ERR(ctx, "Error opening '%s' for writing!\n", filename);
|
||||
return false;
|
||||
@ -229,9 +229,8 @@ static bool write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, const ch
|
||||
ret = avcodec_receive_packet(avctx, pkt);
|
||||
if (ret < 0)
|
||||
goto error_exit;
|
||||
success = true;
|
||||
|
||||
fwrite(pkt->data, pkt->size, 1, fp);
|
||||
success = fwrite(pkt->data, pkt->size, 1, fp) == 1;
|
||||
|
||||
error_exit:
|
||||
avcodec_free_context(&avctx);
|
||||
|
Loading…
Reference in New Issue
Block a user