dir: Don't leak a buffer on a failed Enumerate
authorSimon Wilkinson <sxw@your-file-system.com>
Sun, 23 Oct 2011 15:38:13 +0000 (16:38 +0100)
committerDerrick Brashear <shadow@dementix.org>
Mon, 24 Oct 2011 10:40:57 +0000 (03:40 -0700)
If, for some reasons, Enumerate encounters a hash object with a NULL
buffer pointer, that's no reason to leak the hash object. Make sure
that we DRelease it before failing

Change-Id: I9ba6c69ca524937a6068d33a0ec0a90eef5b88ea
Reviewed-on: http://gerrit.openafs.org/5659
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/dir/dir.c

index 521145b..4e7a844 100644 (file)
@@ -433,8 +433,10 @@ afs_dir_EnumerateDir(dir_file_t dir, int (*proc) (void *, char *name,
                goto out;
 
            ep = (struct DirEntry *)entrybuf.data;
-           if (!ep)
+           if (!ep) {
+               DRelease(&entrybuf, 0);
                break;
+           }
 
            num = ntohs(ep->next);
            code = (*proc) (hook, ep->name, ntohl(ep->fid.vnode),