Cpp: Fix simple symmetric encryption
authorAndre Heinecke <aheinecke@intevation.de>
Tue, 9 Aug 2016 10:56:01 +0000 (12:56 +0200)
committerAndre Heinecke <aheinecke@intevation.de>
Tue, 9 Aug 2016 12:23:51 +0000 (14:23 +0200)
* 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

index 20d827e..814e5a8 100644 (file)
@@ -1113,7 +1113,8 @@ EncryptionResult Context::encrypt(const std::vector<Key> &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));