sink, source: Do not dereference freed memory when freeing the next events
authorFelipe Sateler <fsateler@debian.org>
Fri, 11 Sep 2015 23:15:21 +0000 (20:15 -0300)
committerTanu Kaskinen <tanuk@iki.fi>
Sat, 12 Sep 2015 13:09:24 +0000 (16:09 +0300)
Coverity IDs: 1138197, 1138196

src/pulsecore/sink.c
src/pulsecore/source.c

index c2bf0e4..9ddb527 100644 (file)
@@ -3543,6 +3543,7 @@ static void pa_sink_volume_change_free(pa_sink_volume_change *c) {
 void pa_sink_volume_change_push(pa_sink *s) {
     pa_sink_volume_change *c = NULL;
     pa_sink_volume_change *nc = NULL;
+    pa_sink_volume_change *pc = NULL;
     uint32_t safety_margin = s->thread_info.volume_change_safety_margin;
 
     const char *direction = NULL;
@@ -3600,7 +3601,7 @@ void pa_sink_volume_change_push(pa_sink *s) {
     pa_log_debug("Volume going %s to %d at %llu", direction, pa_cvolume_avg(&nc->hw_volume), (long long unsigned) nc->at);
 
     /* We can ignore volume events that came earlier but should happen later than this. */
-    PA_LLIST_FOREACH(c, nc->next) {
+    PA_LLIST_FOREACH_SAFE(c, pc, nc->next) {
         pa_log_debug("Volume change to %d at %llu was dropped", pa_cvolume_avg(&c->hw_volume), (long long unsigned) c->at);
         pa_sink_volume_change_free(c);
     }
index 2dd7a28..b553a2d 100644 (file)
@@ -2654,6 +2654,7 @@ static void pa_source_volume_change_free(pa_source_volume_change *c) {
 void pa_source_volume_change_push(pa_source *s) {
     pa_source_volume_change *c = NULL;
     pa_source_volume_change *nc = NULL;
+    pa_source_volume_change *pc = NULL;
     uint32_t safety_margin = s->thread_info.volume_change_safety_margin;
 
     const char *direction = NULL;
@@ -2711,7 +2712,7 @@ void pa_source_volume_change_push(pa_source *s) {
     pa_log_debug("Volume going %s to %d at %llu", direction, pa_cvolume_avg(&nc->hw_volume), (long long unsigned) nc->at);
 
     /* We can ignore volume events that came earlier but should happen later than this. */
-    PA_LLIST_FOREACH(c, nc->next) {
+    PA_LLIST_FOREACH_SAFE(c, pc, nc->next) {
         pa_log_debug("Volume change to %d at %llu was dropped", pa_cvolume_avg(&c->hw_volume), (long long unsigned) c->at);
         pa_source_volume_change_free(c);
     }