Commit e73644891c18a0569f27dfaef6fddc1c42ea1902

Authored by Matti Virkkunen
1 parent 30357b06

Better libgcrypt initialization checks + fix throw

libpurple/purpleline_login.cpp
... ... @@ -170,10 +170,15 @@ void PurpleLine::get_auth_token() {
170 170  
171 171 // This may throw.
172 172 std::string PurpleLine::get_encrypted_credentials(line::RSAKey &key) {
173   - if (!gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P)) {
174   - if (!gcry_check_version(GCRYPT_VERSION))
175   - throw new std::runtime_error("libgcrypt version mismatch.");
  173 + if (!gcry_check_version(GCRYPT_VERSION)) {
  174 + std::string err = "libgcrypt version mismatch (compiled: " GCRYPT_VERSION " runtime: ";
  175 + err += gcry_check_version(nullptr);
  176 + err += ")";
  177 +
  178 + throw std::runtime_error(err);
  179 + }
176 180  
  181 + if (!gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P)) {
177 182 gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
178 183  
179 184 gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
... ...