Add routine for checking out-of-memory on get_surrounding_text 47/68847/3
authorsungwook79.park <sungwook79.park@samsung.com>
Tue, 10 May 2016 06:10:33 +0000 (15:10 +0900)
committersungwook79.park <sungwook79.park@samsung.com>
Tue, 10 May 2016 06:25:22 +0000 (15:25 +0900)
Change-Id: I3959bb4fc3dfcf294eee753d9971d822a32bf6f2
Signed-off-by: sungwook79.park <sungwook79.park@samsung.com>
include/inputmethod.h
src/inputmethod.cpp

index 27e1b9a..7aa9a43 100644 (file)
@@ -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()
  */
index 01c08e6..356e030 100644 (file)
@@ -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;