Manage when the string length is zero
authordahyeong.kim <dahyeong.kim@samsung.com>
Thu, 18 Apr 2013 07:43:43 +0000 (16:43 +0900)
committerdahyeong.kim <dahyeong.kim@samsung.com>
Thu, 18 Apr 2013 07:43:43 +0000 (16:43 +0900)
Change-Id: I09dcb02e136f57ca14afcc5b8e6ad965f8d4015e
Signed-off-by: dahyeong.kim <dahyeong.kim@samsung.com>
src/base/utility/FBaseUtil_IcuConverter.cpp

index ae410f8..f58d955 100644 (file)
@@ -208,6 +208,14 @@ ConvertWcsToMbsN(const wchar_t* pValue)
        SysTryReturn(NID_BASE_UTIL, pValue != null, null, E_INVALID_ARG, "[%s] Invalid argument is used. The pValue is null.", GetErrorMessage(E_INVALID_ARG));
 
        int len = wcslen(pValue);
+       if (len == 0)
+       {
+               char* pRet = new (std::nothrow) char[1];
+               SysTryReturn(NID_BASE_UTIL, pRet != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               pRet[0] = '\0';
+               SetLastResult(E_SUCCESS);
+               return pRet;
+       }
 
        UErrorCode err = U_ZERO_ERROR;
        UConverter* pConverter = ucnv_open("UTF-8", &err);