]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
fix 'use after free' of the htsp logname when the connection to the client is lost.
authorJohn Törnblom <john.tornblom@gmail.com>
Wed, 14 Nov 2012 10:00:50 +0000 (11:00 +0100)
committerJohn Törnblom <john.tornblom@gmail.com>
Wed, 14 Nov 2012 10:00:50 +0000 (11:00 +0100)
src/htsp_server.c

index b8c75be4c343811f1ba0557ee4ef897c65a20bd4..da8d34bddd7b0298f16498eff975e7cfd24c005b 100644 (file)
@@ -1553,11 +1553,6 @@ htsp_serve(int fd, void *opaque, struct sockaddr_in *source,
 
   pthread_mutex_unlock(&global_lock);
 
-  free(htsp.htsp_logname);
-  free(htsp.htsp_peername);
-  free(htsp.htsp_username);
-  free(htsp.htsp_clientname);
-
   pthread_mutex_lock(&htsp.htsp_out_mutex);
   htsp.htsp_writer_run = 0;
   pthread_cond_signal(&htsp.htsp_out_cond);
@@ -1565,6 +1560,11 @@ htsp_serve(int fd, void *opaque, struct sockaddr_in *source,
 
   pthread_join(htsp.htsp_writer_thread, NULL);
 
+  free(htsp.htsp_logname);
+  free(htsp.htsp_peername);
+  free(htsp.htsp_username);
+  free(htsp.htsp_clientname);
+
   htsp_msg_q_t *hmq;
 
   TAILQ_FOREACH(hmq, &htsp.htsp_active_output_queues, hmq_link) {