aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-12-26 01:13:49 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-12-26 01:13:49 +0100
commit954fc854f23740bf2b87240474cbc3c391449916 (patch)
tree7ccce17e9003cc2847488f17657e790e21f68aa5 /libavformat
parent68609edd4acf8ea82889953659ca583f1894f441 (diff)
downloadffmpeg-954fc854f23740bf2b87240474cbc3c391449916.tar.gz
avformat/cache: cleanup cache file on cache write failure
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/cache.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/cache.c b/libavformat/cache.c
index 0746e98d3e..29b4a0687f 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;