Mercurial > libavformat.hg
comparison http.c @ 6107:5ad38b8596b2 libavformat
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
| author | mstorsjo |
|---|---|
| date | Tue, 08 Jun 2010 11:18:22 +0000 |
| parents | 44ee60d0c688 |
| children | 117b1826ce8e |
comparison
equal
deleted
inserted
replaced
| 6106:44ee60d0c688 | 6107:5ad38b8596b2 |
|---|---|
| 129 } | 129 } |
| 130 return 0; | 130 return 0; |
| 131 fail: | 131 fail: |
| 132 if (hd) | 132 if (hd) |
| 133 url_close(hd); | 133 url_close(hd); |
| 134 s->hd = NULL; | |
| 134 return AVERROR(EIO); | 135 return AVERROR(EIO); |
| 135 } | 136 } |
| 136 | 137 |
| 137 static int http_open(URLContext *h, const char *uri, int flags) | 138 static int http_open(URLContext *h, const char *uri, int flags) |
| 138 { | 139 { |
| 147 h->priv_data = s; | 148 h->priv_data = s; |
| 148 s->filesize = -1; | 149 s->filesize = -1; |
| 149 s->chunksize = -1; | 150 s->chunksize = -1; |
| 150 s->off = 0; | 151 s->off = 0; |
| 151 s->init = 0; | 152 s->init = 0; |
| 153 s->hd = NULL; | |
| 152 *s->headers = '\0'; | 154 *s->headers = '\0'; |
| 153 memset(&s->auth_state, 0, sizeof(s->auth_state)); | 155 memset(&s->auth_state, 0, sizeof(s->auth_state)); |
| 154 av_strlcpy(s->location, uri, URL_SIZE); | 156 av_strlcpy(s->location, uri, URL_SIZE); |
| 155 | 157 |
| 156 return 0; | 158 return 0; |
| 450 if ((h->flags & URL_WRONLY) && s->chunksize != -1) { | 452 if ((h->flags & URL_WRONLY) && s->chunksize != -1) { |
| 451 ret = url_write(s->hd, footer, sizeof(footer) - 1); | 453 ret = url_write(s->hd, footer, sizeof(footer) - 1); |
| 452 ret = ret > 0 ? 0 : ret; | 454 ret = ret > 0 ? 0 : ret; |
| 453 } | 455 } |
| 454 | 456 |
| 455 url_close(s->hd); | 457 if (s->hd) |
| 458 url_close(s->hd); | |
| 456 av_free(s); | 459 av_free(s); |
| 457 return ret; | 460 return ret; |
| 458 } | 461 } |
| 459 | 462 |
| 460 static int64_t http_seek(URLContext *h, int64_t off, int whence) | 463 static int64_t http_seek(URLContext *h, int64_t off, int whence) |
