btrfs_scan_one_dir: avoid use-after-free on error path
authorJim Meyering <jim@meyering.net>
Wed, 11 Apr 2012 14:42:50 +0000 (16:42 +0200)
committerHugo Mills <hugo@carfax.org.uk>
Tue, 5 Jun 2012 18:56:20 +0000 (19:56 +0100)
commit0195702a0963619f833e2286a98251f841e66047
tree2309bb8a1021af5f4bbcaff2091ad3185646e2fc
parenteda76e46296549517ef3c437c0c6270372bd511d
btrfs_scan_one_dir: avoid use-after-free on error path

If we iterate the "goto again" loop, we've called "closedir(dirp)",
yet at the top of the loop, upon malloc failure we "goto fail",
where we test dirp and if non-NULL, call closedir(dirp) again.
* utils.c (btrfs_scan_one_dir): Clear "dirp" after closedir to avoid
use-after-free upon failed fullpath = malloc(...

Signed-off-by: Jim Meyering <meyering@redhat.com>
utils.c