diff --git a/cpp/pubnub_common.hpp b/cpp/pubnub_common.hpp index 3f49ad00..a4377add 100644 --- a/cpp/pubnub_common.hpp +++ b/cpp/pubnub_common.hpp @@ -664,11 +664,13 @@ class crypto_module: public into_crypto_provider_ptr { * @return The encrypted buffer */ std::vector encrypt(std::vector& to_encrypt) { + to_encrypt.push_back('\0'); pubnub_bymebl_t to_encrypt_c; to_encrypt_c.ptr = to_encrypt.data(); to_encrypt_c.size = to_encrypt.size(); pubnub_bymebl_t result = this->d_module->encrypt(this->d_module, to_encrypt_c); + to_encrypt.pop_back(); if (result.ptr == nullptr) { throw std::runtime_error("crypto_module::encrypt: Encryption failed!"); @@ -685,11 +687,13 @@ class crypto_module: public into_crypto_provider_ptr { * @return The decrypted buffer */ std::vector decrypt(std::vector& to_decrypt) { + to_encrypt.push_back('\0'); pubnub_bymebl_t to_decrypt_c; to_decrypt_c.ptr = to_decrypt.data(); to_decrypt_c.size = to_decrypt.size(); pubnub_bymebl_t result = this->d_module->decrypt(this->d_module, to_decrypt_c); + to_encrypt.pop_back(); if (result.ptr == nullptr) { throw std::runtime_error("crypto_module::decrypt: Decryption failed!");