* lib/tcbfuncs.c: Do not free path before its last use.

This commit is contained in:
nekral-guest 2010-03-18 00:02:17 +00:00
parent aa35a8e46e
commit 8402479e16
2 changed files with 3 additions and 1 deletions

View File

@ -10,6 +10,7 @@
* lib/tcbfuncs.c: Avoid implicit conversion of pointers or * lib/tcbfuncs.c: Avoid implicit conversion of pointers or
integers to booleans. integers to booleans.
* lib/tcbfuncs.c: Avoid assignments in comparisons. * lib/tcbfuncs.c: Avoid assignments in comparisons.
* lib/tcbfuncs.c: Do not free path before its last use.
2010-03-17 Nicolas François <nicolas.francois@centraliens.net> 2010-03-17 Nicolas François <nicolas.francois@centraliens.net>

View File

@ -126,11 +126,12 @@ static char *shadowtcb_path_rel_existing(const char *name)
return NULL; return NULL;
} }
ret = readlink(path, link, sizeof(link) - 1); ret = readlink(path, link, sizeof(link) - 1);
free(path);
if (ret == -1) { if (ret == -1) {
fprintf(stderr, _("%s: Cannot read symbolic link %s: %s\n"), Prog, path, strerror(errno)); fprintf(stderr, _("%s: Cannot read symbolic link %s: %s\n"), Prog, path, strerror(errno));
free(path);
return NULL; return NULL;
} }
free(path);
if (ret >= sizeof(link) - 1) { if (ret >= sizeof(link) - 1) {
link[sizeof(link) - 1] = '\0'; link[sizeof(link) - 1] = '\0';
fprintf(stderr, _("%s: Suspiciously long symlink: %s\n"), Prog, link); fprintf(stderr, _("%s: Suspiciously long symlink: %s\n"), Prog, link);