On 18/10/14 19:53, Vittorio Giovara wrote:
On Sat, Oct 18, 2014 at 5:04 PM, Luca Barbato <[email protected]> wrote:
On 18/10/14 17:58, Vittorio Giovara wrote:
From: Michael Niedermayer <[email protected]>
CC: [email protected]
Bug-Id: CID 1135748
---
libavformat/hdsenc.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index 53fef33..f41381d 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -204,7 +204,10 @@ static int write_manifest(AVFormatContext *s, int
final)
avio_printf(out, "</manifest>\n");
avio_flush(out);
avio_close(out);
- rename(temp_filename, filename);
+ if (rename(temp_filename, filename) == -1) {
+ av_log(s, AV_LOG_ERROR, "failed to rename file %s to %s\n",
temp_filename, filename);
+ return AVERROR(errno);
wrong, errno gets reset by av_log and you return 0;
Nice catch!
Should errno be saved before the av_log, should we return ret directly
or is there another way to fix this altogether?
The options (mostly for future reference)
```
#define av_rename(A, B) (void)rename(A, B)
```
If we do not care about rename failing (we do I think) the nicest way is
```
int av_rename(const char *dest, cost char *src) {
if (rename(dest, src) < 0)
return AVERROR(errno);
}
```
And then you can use it as a normal function w/out having to care about
errno handling.
lu
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel