From 5894ad2a527a1624a87ec430dd8116226afb57e3 Mon Sep 17 00:00:00 2001 From: Danilo Chang Date: Wed, 29 Mar 2023 13:50:38 +0800 Subject: [PATCH] Add code to check OpenCC handle For OpenCC open failed case --- src/engine.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/engine.c b/src/engine.c index 7aaf8de..e8cc454 100644 --- a/src/engine.c +++ b/src/engine.c @@ -108,7 +108,7 @@ static gboolean is_output_simplified; static gboolean is_aux_shown = FALSE; static ArrayContext *array_context = NULL; #ifdef HAVE_OPENCC -static opencc_t cc_handle; +static opencc_t cc_handle = NULL;; #endif GType ibus_array_engine_get_type (void) { @@ -173,7 +173,8 @@ void ibus_array_init (IBusBus *bus) { void ibus_array_exit (void) { #ifdef HAVE_OPENCC - opencc_close(cc_handle); + if (cc_handle) + opencc_close(cc_handle); #endif array_release_context(array_context); @@ -442,7 +443,7 @@ static gboolean ibus_array_engine_commit_current_candidate (IBusArrayEngine *arr } #ifdef HAVE_OPENCC - if (is_output_simplified) { + if (is_output_simplified && cc_handle != NULL) { char *converted = opencc_convert_utf8(cc_handle, text->text, strlen(text->text));