Commit 98170b6c authored by bcoudurier's avatar bcoudurier

restore old buffer content when seek failed in http protocol, fix issue #1631

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@21208 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent f4772554
...@@ -394,6 +394,8 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence) ...@@ -394,6 +394,8 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
HTTPContext *s = h->priv_data; HTTPContext *s = h->priv_data;
URLContext *old_hd = s->hd; URLContext *old_hd = s->hd;
int64_t old_off = s->off; int64_t old_off = s->off;
uint8_t old_buf[BUFFER_SIZE];
int old_buf_size;
if (whence == AVSEEK_SIZE) if (whence == AVSEEK_SIZE)
return s->filesize; return s->filesize;
...@@ -401,6 +403,8 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence) ...@@ -401,6 +403,8 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
return -1; return -1;
/* we save the old context in case the seek fails */ /* we save the old context in case the seek fails */
old_buf_size = s->buf_end - s->buf_ptr;
memcpy(old_buf, s->buf_ptr, old_buf_size);
s->hd = NULL; s->hd = NULL;
if (whence == SEEK_CUR) if (whence == SEEK_CUR)
off += s->off; off += s->off;
...@@ -410,6 +414,9 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence) ...@@ -410,6 +414,9 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
/* if it fails, continue on old connection */ /* if it fails, continue on old connection */
if (http_open_cnx(h) < 0) { if (http_open_cnx(h) < 0) {
memcpy(s->buffer, old_buf, old_buf_size);
s->buf_ptr = s->buffer;
s->buf_end = s->buffer + old_buf_size;
s->hd = old_hd; s->hd = old_hd;
s->off = old_off; s->off = old_off;
return -1; return -1;
......
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