SVACE warnings fixed for HEAP_INCOMPATIBLE.FREE 51/157051/3
authorJaroslaw Pelczar <j.pelczar@samsung.com>
Fri, 20 Oct 2017 15:44:20 +0000 (17:44 +0200)
committerLukasz Kostyra <l.kostyra@samsung.com>
Tue, 24 Oct 2017 08:48:45 +0000 (10:48 +0200)
Change-Id: Ib7f2d61d1aaedb48b4f8c0de045d761119f15355
Signed-off-by: Jaroslaw Pelczar <j.pelczar@samsung.com>
ssflib/dep/swdss/source/file_op.cpp
ssflib/dep/swdss/source/secure_file.cpp
ssflib/dep/swdss/source/ss_temp_store.cpp

index db18c18..38d135d 100644 (file)
@@ -16,6 +16,7 @@
 
 
 #include "file_op.h"
+#include "Osal.h"
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
@@ -116,7 +117,7 @@ int file_op::read_file(const char* filename, unsigned char** buffer,
     }
 
        /* allocating data buffer with enough size */
-       *buffer = new uint8_t[size];
+       *buffer = (unsigned char *)OsaMalloc(size);
        if (!(*buffer)) {
                SLOGD("[%s][%d] Can't malloc pBuffer to 'fread'. ", __FUNCTION__, __LINE__);
                fclose(file);
index d1cfbda..3fdc18f 100644 (file)
@@ -20,6 +20,7 @@
 #include <ctype.h>
 #include "ss_misc.h"
 #include "OsaLinuxUser.h"
+#include <new>
 
 #ifdef _SECOS_SIM_
 #include "file_op.h"
@@ -129,7 +130,7 @@ static int MDeriveUniqueKey2(const CBT_OCTET* pKeyMaterial,
                return SS_RET_INTERNAL_ERROR;
        }
 
-       pBuffer = new CBT_OCTET[uKeyMaterialSize + 16];
+       pBuffer = new(std::nothrow) CBT_OCTET[uKeyMaterialSize + 16];
        if (!pBuffer) {
                SLOGE("Alloc memory failed.\n");
                return SS_RET_MALLOC_FAILED;
@@ -1061,7 +1062,7 @@ int secure_file::serialize_data(unsigned char** buffer,
                                        __FUNCTION__,
                                        __LINE__,
                                        FileStructureType(m_file_content.m_pFileHeader));
-                       delete data;
+                       OsaFree(data);
                        return SS_RET_FAIL;
                }
                break;
@@ -1082,11 +1083,11 @@ int secure_file::serialize_data(unsigned char** buffer,
 int secure_file::write_temp_store(unsigned char* data, unsigned int size) {
        if (-1 == m_cache->write(m_full_path, data, size)) {
                SLOGI("[%s][%d] Writing to cache storage failed.", __FUNCTION__, __LINE__);
-               delete data;
+               OsaFree(data);
                return SS_RET_FAIL;
        }
 
-       delete data;
+       OsaFree(data);
        return SS_RET_SUCCESS;
 }
 
index dc272d1..a2d1fde 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "ss_temp_store.h"
 #include "slog.h"
+#include <new>
 
 #define SS_NODE_ID_CMP(id1, id2) memcmp(static_cast<void*>(id1),static_cast<void*>(id2),SS_NODE_ID_LEN)
 #define SS_NODE_ID_CPY(dest,src) memcpy(static_cast<void*>(dest),static_cast<void*>(src),SS_NODE_ID_LEN)
@@ -79,7 +80,7 @@ int ss_temp_store::write(char* data_name, unsigned char* data,
                return SS_RET_SUCCESS;
        }
 
-       node = new temp_ss_node;
+       node = new(std::nothrow) temp_ss_node;
        if (NULL == node) {
                SLOGE("Failed to malloc memory.");
                return SS_RET_MALLOC_FAILED;
@@ -90,7 +91,7 @@ int ss_temp_store::write(char* data_name, unsigned char* data,
        node->data = (unsigned char*)OsaMalloc(data_size);
        if (NULL == node->data) {
                SLOGE("Failed to malloc data.");
-               OsaFree(node);
+               delete node;
                return SS_RET_MALLOC_FAILED;
        }