diff options
author | saturneric <[email protected]> | 2024-01-12 06:10:58 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-12 06:10:58 +0000 |
commit | 57cc0c0d4c9a8b72385f5d9323ec70e812992ebc (patch) | |
tree | 1dcd6fe6b1eacadd94478cab32ead4d0a48bfe4e | |
parent | refactor: use QString instead of std::string and improve threading system (diff) | |
download | GpgFrontend-57cc0c0d4c9a8b72385f5d9323ec70e812992ebc.tar.gz GpgFrontend-57cc0c0d4c9a8b72385f5d9323ec70e812992ebc.zip |
fix: slove a heap-use-after-free issue
-rw-r--r-- | src/core/function/gpg/GpgContext.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp index df525534..bc0787a4 100644 --- a/src/core/function/gpg/GpgContext.cpp +++ b/src/core/function/gpg/GpgContext.cpp @@ -196,19 +196,13 @@ class GpgContext::Impl { GF_CORE_LOG_DEBUG("ctx set engine info, db path: {}, app path: {}", database_path, app_path); - const char *app_path_c_str = app_path.toUtf8(); - const char *db_path_c_str = database_path.toUtf8(); + auto app_path_buffer = app_path.toUtf8(); + auto database_path_buffer = database_path.toUtf8(); - if (app_path.isEmpty()) { - app_path_c_str = nullptr; - } - - if (database_path.isEmpty()) { - db_path_c_str = nullptr; - } - - auto err = gpgme_ctx_set_engine_info(ctx, gpgme_get_protocol(ctx), - app_path_c_str, db_path_c_str); + auto err = gpgme_ctx_set_engine_info( + ctx, gpgme_get_protocol(ctx), + app_path.isEmpty() ? nullptr : app_path_buffer, + database_path.isEmpty() ? nullptr : database_path_buffer); assert(CheckGpgError(err) == GPG_ERR_NO_ERROR); return CheckGpgError(err) == GPG_ERR_NO_ERROR; |