From d6f5530e7db4da018caa0da30b1bda443fc7a85e Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Tue, 10 May 2016 15:10:33 +0900 Subject: [PATCH] Add routine for checking out-of-memory on get_surrounding_text Change-Id: I3959bb4fc3dfcf294eee753d9971d822a32bf6f2 Signed-off-by: sungwook79.park --- include/inputmethod.h | 2 ++ src/inputmethod.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/inputmethod.h b/include/inputmethod.h index 27e1b9a..7aa9a43 100644 --- a/include/inputmethod.h +++ b/include/inputmethod.h @@ -49,6 +49,7 @@ typedef enum { IME_ERROR_NO_CALLBACK_FUNCTION = TIZEN_ERROR_IME | 0x0001, /**< Necessary callback function is not set */ IME_ERROR_NOT_RUNNING = TIZEN_ERROR_IME | 0x0002, /**< IME main loop isn't started yet */ IME_ERROR_OPERATION_FAILED = TIZEN_ERROR_IME | 0x0003, /**< Operation failed */ + IME_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< out of memory */ } ime_error_e; /** @@ -1593,6 +1594,7 @@ EXPORT_API int ime_delete_surrounding_text(int offset, int len); * @retval #IME_ERROR_INVALID_PARAMETER Invalid parameter * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function * @retval #IME_ERROR_NOT_RUNNING IME main loop isn't started yet + * @retval #IME_ERROR_OUT_OF_MEMORY Failed to obtain text due to out of memory * * @see ime_delete_surrounding_text() */ diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp index 01c08e6..356e030 100644 --- a/src/inputmethod.cpp +++ b/src/inputmethod.cpp @@ -1099,7 +1099,11 @@ int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, i int cursor = 0; - g_core.get_surrounding_text(maxlen_before, maxlen_after, text, cursor); + int ret = g_core.get_surrounding_text(maxlen_before, maxlen_after, text, cursor); + if (ret == -1) { + LOGW("IME_ERROR_OUR_OF_MEMORY"); + return IME_ERROR_OUT_OF_MEMORY; + } if (cursor_pos) *cursor_pos = cursor; -- 2.7.4