From: Simon Wilkinson Date: Sat, 31 Mar 2012 11:01:46 +0000 (-0400) Subject: fs: Fix bad frees X-Git-Tag: upstream/1.8.0_pre1^2~2599 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=9cbc3b77db818bd65a8ec3c5b804178449c2bb67;p=packages%2Fo%2Fopenafs.git fs: Fix bad frees On an error GetLastComponent was freeing completely the wrong thing. Fix this so it frees the memory it has allocated, and not some random stack pointer. Caught by clang-analyzer Change-Id: I8b65f7ab36647b876fae5cbe59d82fd8d38ce0b7 Reviewed-on: http://gerrit.openafs.org/7093 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/venus/fs.c b/src/venus/fs.c index bfb45e5a9..86ee2b1c8 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -1716,6 +1716,9 @@ GetLastComponent(const char *data, char **outdir, char **outbase, char *dirname = NULL; char *basename = NULL; + *outbase = NULL; + *outdir = NULL; + if (thru_symlink) *thru_symlink = 0; @@ -1800,10 +1803,10 @@ GetLastComponent(const char *data, char **outdir, char **outbase, return 0; out: - if (outdir) - free(outdir); - if (outbase) - free(outbase); + if (dirname) + free(dirname); + if (basename) + free(basename); return -1; }