http: Fail reading if the connection has gone away
authorMartin Storsjö <martin@martin.st>
Sun, 17 Jun 2012 18:15:32 +0000 (21:15 +0300)
committerMartin Storsjö <martin@martin.st>
Sun, 17 Jun 2012 19:56:51 +0000 (22:56 +0300)
This can happen if doing a new request using the same socket,
but the new request failed, which clears the urlcontext.

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/http.c

index b2f2ea9..2b5f2cc 100644 (file)
@@ -510,6 +510,9 @@ static int http_read(URLContext *h, uint8_t *buf, int size)
     HTTPContext *s = h->priv_data;
     int err, new_location;
 
+    if (!s->hd)
+        return AVERROR_EOF;
+
     if (s->end_chunked_post) {
         if (!s->end_header) {
             err = http_read_header(h, &new_location);