Fix issues detected by static analysis tool 14/312914/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 17 Jun 2024 08:08:54 +0000 (17:08 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 17 Jun 2024 08:08:54 +0000 (17:08 +0900)
The pointer returned by operator new can't be null

Change-Id: I13f4004f3fc4743a83be2351a2c3b7b6ef2df4d5
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
scl/file_storage.cpp

index 64d57028e3c61f7d747e65438070faacdd69592b..3bb060fe6f19feb283482ac093cd74e03f9528ec 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include "file_storage_impl.h"
+#include <new>
 
 FileStorage::FileStorage(const IString_Provider* string_provider):
     m_storage(NULL),
@@ -156,7 +157,7 @@ int FileStorage::
         fclose(fp);
         return -1;
     }
-    m_storage = new char[size];
+    m_storage = new(std::nothrow) char[size];
     if (m_storage == NULL) {
         fclose(fp);
         return -1;
@@ -193,7 +194,7 @@ get_storage(const FileStorage& storage, int offset, int block_size) {
         delete[] m_storage;
     }
 
-    m_storage = new char[block_size];
+    m_storage = new(std::nothrow) char[block_size];
     if (m_storage == NULL) {
         return -1;
     }