1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-24 13:56:33 +02:00

avformat/cache: cleanup cache file on cache write failure

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-12-26 01:13:49 +01:00
parent 68609edd4a
commit 954fc854f2

View File

@ -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;