Fix alarm defect for applaunch based logic.
[platform/framework/native/appfw.git] / src / system / FSys_RuntimeInfoImpl.cpp
index 04a688b..b74a1c4 100644 (file)
@@ -397,11 +397,15 @@ _RuntimeInfoImpl::GetDirectorySize(const char* path)
 
        fileLength = strlen(appIdPath.get()) + 29;
        pFileName = (char*)malloc(fileLength);
+       SysTryCatch(NID_SYS, pFileName, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "It is not enough memory.");
+
        ret = sprintf(pFileName, "/tmp/size_of_directory_%s.tmp", appIdPath.get());
        SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to write file path.");
 
        commandLength = strlen(pFileName) + 8;
        pCommand = (char*) malloc(commandLength);
+       SysTryCatch(NID_SYS, pCommand, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "It is not enough memory.");
+
        ret = sprintf(pCommand, "rm -rf %s", pFileName);
        SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to write remove pCommand.");
 
@@ -415,6 +419,8 @@ _RuntimeInfoImpl::GetDirectorySize(const char* path)
 
        commandLength = strlen(pFileName) + strlen(path) + 16;
        pCommand = (char*)malloc(commandLength);
+       SysTryCatch(NID_SYS, pCommand, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "It is not enough memory.");
+
        ret = sprintf(pCommand, "du -skb -P %s >> %s", path, pFileName);
        SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to write du pCommand.");
 
@@ -440,7 +446,7 @@ CATCH:
        }
        if (pCommand)
        {
-               free(pFileName);
+               free(pCommand);
        }
        if (pFile)
        {