audiod: Fix use after free on exit.
authorAndre Noll <maan@systemlinux.org>
Tue, 15 Jul 2014 05:04:07 +0000 (07:04 +0200)
committerAndre Noll <maan@systemlinux.org>
Tue, 15 Jul 2014 05:09:21 +0000 (07:09 +0200)
commit4a8632cfff4c239f1ce285c2a8ffd021386da418
tree4362e1ff28d6d57bec9fb4187954b9768f238fc6
parent227a2ce5446c3f2ef4fd3e7c2ada3bb8d15289f1
audiod: Fix use after free on exit.

client_close() frees the ->ct structure which is used one line later
by task_reap(). valgrind spots this use after free bug and reports

==13497== Invalid read of size 4
==13497==    at 0x8059EA8: task_reap (sched.c:199)
==13497==    by 0x80542FA: close_stat_pipe (audiod.c:1082)
==13497==    by 0x8055632: clean_exit (audiod.c:1159)
==13497==    by 0x80556B6: signal_post_select (audiod.c:1018)
==13497==    by 0x8059E5F: schedule (sched.c:88)
==13497==    by 0x804D41C: main (audiod.c:1437)
==13497==  Address 0x4833c04 is 204 bytes inside a block of size 212 free'd
==13497==    at 0x4028AC0: free (vg_replace_malloc.c:468)
==13497==    by 0x80542E8: close_stat_pipe (audiod.c:1081)
==13497==    by 0x8055632: clean_exit (audiod.c:1159)
==13497==    by 0x80556B6: signal_post_select (audiod.c:1018)
==13497==    by 0x8059E5F: schedule (sched.c:88)
==13497==    by 0x804D41C: main (audiod.c:1437)

The bug was introduced recently in commit 0b43ec5d (task_register()
conversion: client task).
audiod.c