From bf776ce94cf454f1b3f1645b1cde09cd1c54324b Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Tue, 9 Aug 2016 12:56:01 +0200 Subject: [PATCH] Cpp: Fix simple symmetric encryption * lang/cpp/src/context.cpp (Context::encrypt): If no recipients are provided encrypt with NULL and not an empty array. -- Sending an empty array leads to an invalid argument error. --- lang/cpp/src/context.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp index 20d827ec..814e5a82 100644 --- a/lang/cpp/src/context.cpp +++ b/lang/cpp/src/context.cpp @@ -1113,7 +1113,8 @@ EncryptionResult Context::encrypt(const std::vector &recipients, const Data } } *keys_it++ = 0; - d->lasterr = gpgme_op_encrypt(d->ctx, keys, encryptflags2encryptflags(flags), + d->lasterr = gpgme_op_encrypt(d->ctx, recipients.empty() ? nullptr : keys, + encryptflags2encryptflags(flags), pdp ? pdp->data : 0, cdp ? cdp->data : 0); delete[] keys; return EncryptionResult(d->ctx, Error(d->lasterr));