if (num < 1 && ferror(filep)) {
fprintf(stderr, "%s: Unable to write to file (%s): %s\n",
progname, filepnm, strerror(errno));
+ fclose(filep);
goto out_umnt;
}
fclose(filep);
return NULL;
if (devname[0] != '/') {
- if (getcwd(buf, sizeof(buf) - 1) == NULL)
+ if (getcwd(buf, sizeof(buf) - 1) == NULL) {
+ free(path);
return NULL;
+ }
strcat(buf, "/");
strcat(buf, devname);
} else {