]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
httpc: hc->hc_efd might be NULL after cond_wait
authorJaroslav Kysela <perex@perex.cz>
Wed, 9 Dec 2015 20:20:40 +0000 (21:20 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 9 Dec 2015 20:20:40 +0000 (21:20 +0100)
src/httpc.c

index e83367b7cd2248e7d7df53f0ac1161141b56f436..4b7c428e6aa145d94f757ebccc55c014de186734 100644 (file)
@@ -1534,11 +1534,13 @@ http_client_close ( http_client_t *hc )
     hc->hc_shutdown_wait = 1;
     while (hc->hc_running)
       pthread_cond_wait(&http_cond, &http_lock);
-    memset(&ev, 0, sizeof(ev));
-    ev.fd = hc->hc_fd;
-    tvhpoll_rem(hc->hc_efd, &ev, 1);
-    TAILQ_REMOVE(&http_clients, hc, hc_link);
-    hc->hc_efd = NULL;
+    if (hc->hc_efd) {
+      memset(&ev, 0, sizeof(ev));
+      ev.fd = hc->hc_fd;
+      tvhpoll_rem(hc->hc_efd, &ev, 1);
+      TAILQ_REMOVE(&http_clients, hc, hc_link);
+      hc->hc_efd = NULL;
+    }
     pthread_mutex_unlock(&http_lock);
   }
   http_client_shutdown(hc, 1, 0);