1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Fix handling of errors in the http protocol

If http_connect fails, we've already stored the new connection handle in s->hd,
so clear it so http_close won't double-free it.

10l to me for not spotting it during review

Originally committed as revision 23529 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Martin Storsjö 2010-06-08 11:18:22 +00:00
parent 4ceb8b3460
commit 701ea516ee

View File

@ -131,6 +131,7 @@ static int http_open_cnx(URLContext *h)
fail: fail:
if (hd) if (hd)
url_close(hd); url_close(hd);
s->hd = NULL;
return AVERROR(EIO); return AVERROR(EIO);
} }
@ -149,6 +150,7 @@ static int http_open(URLContext *h, const char *uri, int flags)
s->chunksize = -1; s->chunksize = -1;
s->off = 0; s->off = 0;
s->init = 0; s->init = 0;
s->hd = NULL;
*s->headers = '\0'; *s->headers = '\0';
memset(&s->auth_state, 0, sizeof(s->auth_state)); memset(&s->auth_state, 0, sizeof(s->auth_state));
av_strlcpy(s->location, uri, URL_SIZE); av_strlcpy(s->location, uri, URL_SIZE);
@ -452,7 +454,8 @@ static int http_close(URLContext *h)
ret = ret > 0 ? 0 : ret; ret = ret > 0 ? 0 : ret;
} }
url_close(s->hd); if (s->hd)
url_close(s->hd);
av_free(s); av_free(s);
return ret; return ret;
} }