9242350
diff --git a/print-esp.c b/print-esp.c
40612b3
index 6fabff1..5818cc8 100644
9242350
--- a/print-esp.c
9242350
+++ b/print-esp.c
40612b3
@@ -242,6 +242,7 @@ int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
40612b3
 	if (input_buffer == NULL) {
40612b3
 		EVP_CIPHER_CTX_free(ctx);
40612b3
 		(*ndo->ndo_error)(ndo, "can't allocate memory for encrypted data buffer");
9242350
+		return 0;
40612b3
 	}
40612b3
 	/*
40612b3
 	 * Copy the input data to the encrypted data buffer, and pad it
40612b3
@@ -259,7 +260,7 @@ int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
9242350
 		EVP_CIPHER_CTX_free(ctx);
40612b3
 		(*ndo->ndo_error)(ndo, "can't allocate memory for decryption buffer");
9242350
 	}
40612b3
-	EVP_Cipher(ctx, output_buffer, input_buffer, len);
9242350
+	EVP_Cipher(ctx, output_buffer, input_buffer, buffer_size);
9242350
 	EVP_CIPHER_CTX_free(ctx);
9242350
 
9242350
 	/*
40612b3
@@ -815,6 +816,7 @@ esp_print(netdissect_options *ndo,
40612b3
 			if (input_buffer == NULL) {
9242350
 				EVP_CIPHER_CTX_free(ctx);
40612b3
 				(*ndo->ndo_error)(ndo, "can't allocate memory for encrypted data buffer");
40612b3
+				return 0;
9242350
 			}
9242350
 			/*
40612b3
 			 * Copy the input data to the encrypted data buffer,