Bug 536352 - missing null check and memory leak in nsinstall.c. r=ted

This commit is contained in:
Aiken Tie 2010-01-18 11:22:03 +01:00
parent 7853f24858
commit 35627ce397

View File

@ -258,10 +258,15 @@ copydir( char *from, char *to, mode_t mode, char *group, char *owner,
sprintf(destdir, "%s%s%s", to, _DIRECTORY_SEPARATOR, base);
if (mkdirs(destdir, mode) != 0) {
fail("cannot make directory %s\n", destdir);
free(destdir);
return;
}
dir = opendir(from);
if (!(dir = opendir(from))) {
fail("cannot open directory %s\n", from);
free(destdir);
return;
}
direntry = xmalloc((unsigned int)PATH_MAX);
destentry = xmalloc((unsigned int)PATH_MAX);
@ -280,6 +285,7 @@ copydir( char *from, char *to, mode_t mode, char *group, char *owner,
copyfile( direntry, destentry, mode, group, owner, dotimes, uid, gid );
}
free(destdir);
free(direntry);
free(destentry);
closedir(dir);