diff --git a/sm/encrypt.c b/sm/encrypt.c index 42a438a95..ab74fa21d 100644 --- a/sm/encrypt.c +++ b/sm/encrypt.c @@ -208,8 +208,11 @@ encrypt_dek (const DEK dek, ksba_cert_t cert, unsigned char **encval) gcry_sexp_release (s_pkey); /* Reformat it. */ - rc = make_canon_sexp (s_ciph, encval, NULL); - gcry_sexp_release (s_ciph); + if (!rc) + { + rc = make_canon_sexp (s_ciph, encval, NULL); + gcry_sexp_release (s_ciph); + } return rc; }