From 1d8f06511c60727392d2948d074968c5917159ad Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Tue, 19 Mar 2013 16:28:37 +0000 Subject: [PATCH] eet_cipher: Fix initialization of opened variable In the error case we 'goto' the error path directly without passing through the declaration and initialization of the variable. This doesn't work so move the declaration/initialization to the start. See this example (compile with -Wall for the warning): ----- #include int main(void) { goto bar; int i = 15; bar: printf("Foo: %i\n", i); return 0; } ---- Signed-off-by: Daniel Willmann --- src/lib/eet/eet_cipher.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/eet/eet_cipher.c b/src/lib/eet/eet_cipher.c index f805ba7c0b..2dd4d07872 100644 --- a/src/lib/eet/eet_cipher.c +++ b/src/lib/eet/eet_cipher.c @@ -1070,6 +1070,7 @@ eet_decipher(const void *data, unsigned int salt; int tmp_len; int tmp = 0; + int opened = 0; /* At least the salt and an AES block */ if (size < sizeof(unsigned int) + 16) @@ -1129,7 +1130,6 @@ eet_decipher(const void *data, # else /* ifdef HAVE_GNUTLS */ EVP_CIPHER_CTX ctx; - int opened = 0; /* Openssl create the corresponding cipher */ EVP_CIPHER_CTX_init(&ctx); @@ -1178,6 +1178,7 @@ on_error: memset(ik, 0, sizeof (ik)); # ifdef HAVE_GNUTLS + (void)opened; # else if (opened) EVP_CIPHER_CTX_cleanup(&ctx);