Commit 954fc854 authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/cache: cleanup cache file on cache write failure

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 68609edd
...@@ -92,7 +92,7 @@ static int cache_open(URLContext *h, const char *arg, int flags) ...@@ -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) static int add_entry(URLContext *h, const unsigned char *buf, int size)
{ {
Context *c= h->priv_data; Context *c= h->priv_data;
int64_t pos; int64_t pos = -1;
int ret; int ret;
CacheEntry *entry = av_malloc(sizeof(*entry)); CacheEntry *entry = av_malloc(sizeof(*entry));
CacheEntry *entry_ret; CacheEntry *entry_ret;
...@@ -132,6 +132,8 @@ static int add_entry(URLContext *h, const unsigned char *buf, int size) ...@@ -132,6 +132,8 @@ static int add_entry(URLContext *h, const unsigned char *buf, int size)
return 0; return 0;
fail: fail:
if (pos >= 0)
ftruncate(c->fd, pos);
av_free(entry); av_free(entry);
av_free(node); av_free(node);
return ret; return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment