util-lib: add cleanup function for crypt_free

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2017-11-30 20:43:25 +01:00
parent 40fd52f28d
commit 294bd45470
5 changed files with 45 additions and 32 deletions
+2 -4
View File
@@ -28,6 +28,7 @@
#include "alloc-util.h"
#include "ask-password-api.h"
#include "crypt-util.h"
#include "device-util.h"
#include "escape.h"
#include "fileio.h"
@@ -604,7 +605,7 @@ static int help(void) {
}
int main(int argc, char *argv[]) {
struct crypt_device *cd = NULL;
_cleanup_(crypt_freep) struct crypt_device *cd = NULL;
int r = -EINVAL;
if (argc <= 1) {
@@ -766,9 +767,6 @@ int main(int argc, char *argv[]) {
r = 0;
finish:
if (cd)
crypt_free(cd);
free(arg_cipher);
free(arg_hash);
free(arg_header);