add checking nullptr of value to fix svace 74/322074/1
authordyamy-lee <dyamy.lee@samsung.com>
Thu, 3 Apr 2025 07:19:47 +0000 (16:19 +0900)
committerdyamy-lee <dyamy.lee@samsung.com>
Thu, 3 Apr 2025 07:19:47 +0000 (16:19 +0900)
Change-Id: Id38b7ddc3bb052528a45de81b910a4f37a8f2189

src/mmi/mmi-data.cpp
src/mmi/mmi-primitive-value.cpp

index 5df558a1f2ef88085cb9d68d69b05158f57e0a89..3009c3234747ad8d5b17ac8b94799a71a52bb120 100644 (file)
@@ -1060,6 +1060,12 @@ int mmi_data_from_bytes(unsigned char *bytes, size_t length, mmi_data_h *data) {
         memcpy(&datalen, current, sizeof(size_t));
         current += sizeof(size_t);
         auto value = reinterpret_cast<mmi_data_h>(malloc(sizeof(mmi_data_s)));
+        if (nullptr == value) {
+// LCOV_EXCL_START
+            _E("[ERROR] Failed to allocate memory");
+            return MMI_ERROR_OUT_OF_MEMORY;
+// LCOV_EXCL_STOP
+        }
         value->type = type;
         value->datalen = 0;
         value->data = nullptr;
index ca063720629f8ba0fc7d1c43dc7d910ba45843e0..2b405e82458a710b1bc4672d8e3e5f46ef74def7 100644 (file)
@@ -610,6 +610,12 @@ int mmi_primitive_value_from_bytes(unsigned char *bytes, size_t size, mmi_primit
         memcpy(&datalen, current, sizeof(size_t));
         current += sizeof(size_t);
         auto value = reinterpret_cast<mmi_primitive_value_s *>(malloc(sizeof(mmi_primitive_value_s)));
+        if (nullptr == value) {
+// LCOV_EXCL_START
+            _E("[ERROR] Failed to allocate memory");
+            return MMI_ERROR_OUT_OF_MEMORY;
+// LCOV_EXCL_STOP
+        }
         value->type = type;
         value->datalen = 0;
         value->data = nullptr;