[FFmpeg-cvslog] avformat/cache: cleanup cache file on cache write failure
Michael Niedermayer
git at videolan.org
Fri Dec 26 02:23:13 CET 2014
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Dec 26 01:13:49 2014 +0100| [954fc854f23740bf2b87240474cbc3c391449916] | committer: Michael Niedermayer
avformat/cache: cleanup cache file on cache write failure
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=954fc854f23740bf2b87240474cbc3c391449916
---
libavformat/cache.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libavformat/cache.c b/libavformat/cache.c
index 0746e98..29b4a06 100644
--- a/libavformat/cache.c
+++ b/libavformat/cache.c
@@ -92,7 +92,7 @@ static int cache_open(URLContext *h, const char *arg, int flags)
static int add_entry(URLContext *h, const unsigned char *buf, int size)
{
Context *c= h->priv_data;
- int64_t pos;
+ int64_t pos = -1;
int ret;
CacheEntry *entry = av_malloc(sizeof(*entry));
CacheEntry *entry_ret;
@@ -132,6 +132,8 @@ static int add_entry(URLContext *h, const unsigned char *buf, int size)
return 0;
fail:
+ if (pos >= 0)
+ ftruncate(c->fd, pos);
av_free(entry);
av_free(node);
return ret;
More information about the ffmpeg-cvslog
mailing list