From 4552680b7d23d27cf933df6805c26ac3fce1a550 Mon Sep 17 00:00:00 2001 From: Seoyeon Kim Date: Thu, 5 Sep 2019 15:19:26 +0900 Subject: [PATCH] Fix SVACE / Coverity issue - After having been compared to NULL value at input-method-context-impl-ecore-wl.cpp:605, pointer 'plainText' is dereferenced at 618 line by calling function 'strdup'. Change-Id: Ieeeda41d8eab2f3310c0a9d58aa8251e70e2cfd7 Signed-off-by: Seoyeon Kim --- .../input-method-context-impl-ecore-wl.cpp | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp index 73b1a43..b5bf294 100755 --- a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp +++ b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp @@ -604,33 +604,36 @@ bool InputMethodContextEcoreWl::RetrieveSurrounding( void* data, ImfContext* imf if( callbackData.update ) { + if( cursorPosition ) + { + mIMFCursorPosition = static_cast( callbackData.cursorPosition ); + *cursorPosition = mIMFCursorPosition; + } + if( text ) { const char* plainText = callbackData.currentText.c_str(); + if( plainText ) { + // The memory allocated by strdup() can be freed by ecore_imf_context_surrounding_get() internally. + *text = strdup( plainText ); + // If the current input panel is password mode, dali should replace the plain text with '*' (Asterisk) character. if( ecore_imf_context_input_hint_get( mIMFContext ) & ECORE_IMF_INPUT_HINT_SENSITIVE_DATA ) { - char* iter = NULL; - for( iter = const_cast( plainText ); iter && *iter; ++iter ) + for( char* iter = *text; *iter; ++iter ) { *iter = '*'; } } - } - // The memory allocated by strdup() can be freed by ecore_imf_context_surrounding_get() internally. - *text = strdup( plainText ); - } - if( cursorPosition ) - { - mIMFCursorPosition = static_cast( callbackData.cursorPosition ); - *cursorPosition = mIMFCursorPosition; + return EINA_TRUE; + } } } - return EINA_TRUE; + return EINA_FALSE; } /** -- 2.7.4