Fix N_SE-32099 : zero length string may not save to setting.xml
authorSeungWon Lee <lsw2000.lee@samsung.com>
Thu, 4 Apr 2013 12:45:00 +0000 (21:45 +0900)
committerSeungWon Lee <lsw2000.lee@samsung.com>
Thu, 4 Apr 2013 12:45:00 +0000 (21:45 +0900)
Change-Id: I1fba257362afe98018eec70790a9f83433a44f32
Signed-off-by: SeungWon Lee <lsw2000.lee@samsung.com>
src/app/FApp_AppSettingImpl.cpp

index 4502758..949a767 100644 (file)
@@ -948,10 +948,10 @@ _AppSettingImpl::UpdateProperty(xmlNodePtr pNode, const String& value)
 {
        const xmlChar* pPropValue = reinterpret_cast<const xmlChar*>("value");
 
-       std::unique_ptr<ByteBuffer> pBuf(Tizen::Base::Utility::StringUtil::StringToUtf8N(value));
-       if (pBuf)
+       if (value.IsEmpty())
        {
-               xmlAttrPtr attrPtr = xmlSetProp(pNode, pPropValue, reinterpret_cast<const xmlChar*>(pBuf->GetPointer()));
+               const xmlChar* pZeroLength = reinterpret_cast<const xmlChar*>("");
+               xmlAttrPtr attrPtr = xmlSetProp(pNode, pPropValue, pZeroLength);
                if (attrPtr)
                {
                        return true;
@@ -959,7 +959,19 @@ _AppSettingImpl::UpdateProperty(xmlNodePtr pNode, const String& value)
        }
        else
        {
-               SysLog(NID_APP, "StringToUtf8N is failed.");
+               std::unique_ptr<ByteBuffer> pBuf(Tizen::Base::Utility::StringUtil::StringToUtf8N(value));
+               if (pBuf)
+               {
+                       xmlAttrPtr attrPtr = xmlSetProp(pNode, pPropValue, reinterpret_cast<const xmlChar*>(pBuf->GetPointer()));
+                       if (attrPtr)
+                       {
+                               return true;
+                       }
+               }
+               else
+               {
+                       SysLog(NID_APP, "StringToUtf8N is failed.");
+               }
        }
        return false;
 }