aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg/GpgContext.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2023-12-16 05:41:38 +0000
committersaturneric <[email protected]>2023-12-16 05:41:38 +0000
commitd6311ece3fa3e8e976befa7e253d453398046c7c (patch)
treea23183865059d06ee7796214d9747b8bf334016c /src/core/function/gpg/GpgContext.cpp
parentfix: clean up envirnoment when app exits (diff)
downloadGpgFrontend-d6311ece3fa3e8e976befa7e253d453398046c7c.tar.gz
GpgFrontend-d6311ece3fa3e8e976befa7e253d453398046c7c.zip
fix: slove memory problem of gpg context
Diffstat (limited to 'src/core/function/gpg/GpgContext.cpp')
-rw-r--r--src/core/function/gpg/GpgContext.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp
index f7223e13..7cde439c 100644
--- a/src/core/function/gpg/GpgContext.cpp
+++ b/src/core/function/gpg/GpgContext.cpp
@@ -280,14 +280,12 @@ class GpgContext::Impl {
assert(p_ctx != nullptr);
binary_ctx_ref_ = p_ctx;
- // if (!common_ctx_initialize(binary_ctx_ref_, args)) {
- // SPDLOG_ERROR("get new ctx failed, binary");
- // return false;
- // }
-
- // /** Setting the output type must be done at the beginning */
- // /** think this means ascii-armor --> ? */
- // gpgme_set_armor(binary_ctx_ref_, 0);
+ if (!common_ctx_initialize(binary_ctx_ref_, args)) {
+ SPDLOG_ERROR("get new ctx failed, binary");
+ return false;
+ }
+
+ gpgme_set_armor(binary_ctx_ref_, 0);
return true;
}
@@ -300,11 +298,11 @@ class GpgContext::Impl {
assert(p_ctx != nullptr);
ctx_ref_ = p_ctx;
- // if (!common_ctx_initialize(ctx_ref_, args)) {
- // return false;
- // }
+ if (!common_ctx_initialize(ctx_ref_, args)) {
+ return false;
+ }
- // gpgme_set_armor(ctx_ref_, 1);
+ gpgme_set_armor(ctx_ref_, 1);
return true;
}
};
@@ -313,7 +311,7 @@ GpgContext::GpgContext(int channel)
: SingletonFunctionObject<GpgContext>(channel),
p_(SecureCreateUniqueObject<Impl>(this, GpgContextInitArgs{})) {}
-GpgContext::GpgContext(const GpgContextInitArgs &args, int channel)
+GpgContext::GpgContext(GpgContextInitArgs args, int channel)
: SingletonFunctionObject<GpgContext>(channel),
p_(SecureCreateUniqueObject<Impl>(this, args)) {}