mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Fix some memory leaks (thanks to okozina).
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@610 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
@@ -169,7 +169,7 @@ char *crypt_lookup_dev(const char *dev_id)
|
||||
|
||||
static int crypt_sysfs_get_major_minor(const char *kname, int *major, int *minor)
|
||||
{
|
||||
char path[PATH_MAX], tmp[64];
|
||||
char path[PATH_MAX], tmp[64] = {0};
|
||||
int fd, r = 0;
|
||||
|
||||
if (snprintf(path, sizeof(path), "/sys/block/%s/dev", kname) < 0)
|
||||
@@ -180,7 +180,11 @@ static int crypt_sysfs_get_major_minor(const char *kname, int *major, int *minor
|
||||
r = read(fd, tmp, sizeof(tmp));
|
||||
close(fd);
|
||||
|
||||
if (r <= 0 || sscanf(tmp, "%d:%d", major, minor) != 2)
|
||||
if (r <= 0)
|
||||
return 0;
|
||||
|
||||
tmp[63] = '\0';
|
||||
if (sscanf(tmp, "%d:%d", major, minor) != 2)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -1046,6 +1046,7 @@ static __attribute__ ((noreturn)) void usage(poptContext popt_context,
|
||||
poptPrintUsage(popt_context, stderr, 0);
|
||||
if (error)
|
||||
log_err("%s: %s\n", more, error);
|
||||
poptFreeContext(popt_context);
|
||||
exit(exitcode);
|
||||
}
|
||||
|
||||
@@ -1234,6 +1235,7 @@ int main(int argc, const char **argv)
|
||||
poptBadOption(popt_context, POPT_BADOPTION_NOALIAS));
|
||||
if (opt_version_mode) {
|
||||
log_std("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
|
||||
poptFreeContext(popt_context);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1345,5 +1347,7 @@ int main(int argc, const char **argv)
|
||||
_dbg_version_and_cmd(argc, argv);
|
||||
}
|
||||
|
||||
return run_action(action);
|
||||
r = run_action(action);
|
||||
poptFreeContext(popt_context);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -355,6 +355,12 @@ static void _cleanup(void)
|
||||
remove(BACKUP_FILE);
|
||||
|
||||
_remove_keyfiles();
|
||||
|
||||
free(tmp_file_1);
|
||||
free(test_loop_file);
|
||||
free(THE_LOOP_DEV);
|
||||
free(DEVICE_1);
|
||||
free(DEVICE_2);
|
||||
}
|
||||
|
||||
static int _setup(void)
|
||||
|
||||
Reference in New Issue
Block a user