]> git.tue.mpg.de Git - paraslash.git/commitdiff
audiod: fix a memory leak in ringbuffer handling
authorAndre <maan@p133.(none)>
Fri, 10 Mar 2006 01:32:12 +0000 (02:32 +0100)
committerAndre <maan@p133.(none)>
Fri, 10 Mar 2006 01:32:12 +0000 (02:32 +0100)
Found by valgrind.

audiod.c

index ccc3f9b962b5d7627d16026b5820b0f9ab9a882f..cd43f24f47fa31beb27184a39f6dcd560fe3fb3e 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -569,7 +569,7 @@ static void close_stat_pipe(void)
        stat_pipe = -1;
        kill_all_decoders();
        for (i = 0; i < RINGBUFFER_SIZE; i++)
-               ringbuffer_add(stat_item_ringbuf, para_strdup(NULL));
+               free(ringbuffer_add(stat_item_ringbuf, para_strdup(NULL)));
        dump_empty_status();
        length_seconds = 0;
        offset_seconds = 0;
@@ -577,9 +577,8 @@ static void close_stat_pipe(void)
        playing = 0;
        msg = make_message("%s:no connection to para_server\n",
                status_item_list[SI_STATUS_BAR]);
-       ringbuffer_add(stat_item_ringbuf, msg);
+       free(ringbuffer_add(stat_item_ringbuf, msg));
        stat_client_write(msg);
-       free(msg);
 }
 
 static void __noreturn clean_exit(int status, const char *msg)
@@ -806,7 +805,7 @@ static void check_stat_line(char *line)
 
        if (!line)
                return;
-       ringbuffer_add(stat_item_ringbuf, line);
+       free(ringbuffer_add(stat_item_ringbuf, para_strdup(line)));
        stat_client_write(line);
        itemnum = stat_line_valid(line);
        if (itemnum < 0)