: libblktapctl, fix use-after-free bug
PATCH 1/1 : libblktapctl, fix use-after-free bug
This has not caused crashes because generally use after free is OK provided nothing else is going on. However the patch makes things correct. It also allows us to use heap poisoning feature of valgrind on tools linking to libblktapctl.
tools/blktap2/control/tap-ctl-list.c +2 -2
@@ -385,9 +385,9 @@ _tap_ctl_free_tapdisks(struct tapdisk *tstruct tapdisk *tap;for (tap = tapv; tap < &tapv[n_taps]; ++tap) { -struct tapdisk_list *tl; +struct tapdisk_list *tl, *next; -list_for_each_entry (tl, &tap->list, entry) { +list_for_each_entry_safe (tl, next, &tap->list, entry) {free (tl->params);free (tl); }