summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-25 13:18:47 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-10-25 13:28:51 +0200
commitdd5c2fe17727cba76122ee9a4cfc1ad07a2dd099 (patch)
treec69684cbb1519587ff4f5a21fa52460a810ab4cb
parent2fc970a6b84504f54883a25482de466b49b11fd8 (diff)
downloadffmpeg-dd5c2fe17727cba76122ee9a4cfc1ad07a2dd099.tar.gz
avcodec: Read errno before av_log() as the callback from av_log() might affect errno
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/libxvid_rc.c3
-rw-r--r--libavcodec/utils.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/libavcodec/libxvid_rc.c b/libavcodec/libxvid_rc.c
index 4ee4d822ff..f92bef153a 100644
--- a/libavcodec/libxvid_rc.c
+++ b/libavcodec/libxvid_rc.c
@@ -68,10 +68,11 @@ av_cold int ff_xvid_rate_control_init(MpegEncContext *s)
(rce->header_bits + rce->mv_bits + 7) / 8);
if (write(fd, tmp, strlen(tmp)) < 0) {
+ int ret = AVERROR(errno);
av_log(NULL, AV_LOG_ERROR, "Error %s writing 2pass logfile\n", strerror(errno));
av_free(tmp_name);
close(fd);
- return AVERROR(errno);
+ return ret;
}
}
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4ef2ac62d5..b6ae1c0a7f 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1664,9 +1664,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
#if CONFIG_ICONV
iconv_t cd = iconv_open("UTF-8", avctx->sub_charenc);
if (cd == (iconv_t)-1) {
+ ret = AVERROR(errno);
av_log(avctx, AV_LOG_ERROR, "Unable to open iconv context "
"with input character encoding \"%s\"\n", avctx->sub_charenc);
- ret = AVERROR(errno);
goto free_and_end;
}
iconv_close(cd);
@@ -2649,10 +2649,10 @@ static int recode_subtitle(AVCodecContext *avctx,
if (iconv(cd, &inb, &inl, &outb, &outl) == (size_t)-1 ||
iconv(cd, NULL, NULL, &outb, &outl) == (size_t)-1 ||
outl >= outpkt->size || inl != 0) {
+ ret = FFMIN(AVERROR(errno), -1);
av_log(avctx, AV_LOG_ERROR, "Unable to recode subtitle event \"%s\" "
"from %s to UTF-8\n", inpkt->data, avctx->sub_charenc);
av_free_packet(&tmp);
- ret = AVERROR(errno);
goto end;
}
outpkt->size -= outl;