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 <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
This commit is contained in:
Simon Wilkinson 2012-03-31 07:01:46 -04:00 committed by Derrick Brashear
parent 9a007a9df4
commit 9cbc3b77db

View File

@ -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;
}