From 8b0d0b4732b82a6f3c35bbdd3a7e9f791ce20f11 Mon Sep 17 00:00:00 2001 From: Hosung Kim Date: Thu, 7 Mar 2024 16:11:46 +0900 Subject: [PATCH] fix: resolve static analysis defects Signed-off-by: Hosung Kim hs852.kim@samsung.com --- deps/node/src/memory_tracker-inl.h | 4 +++- src/lwnode/lwnode-loader.cc | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/deps/node/src/memory_tracker-inl.h b/deps/node/src/memory_tracker-inl.h index 4167064847..58cd94ee35 100644 --- a/deps/node/src/memory_tracker-inl.h +++ b/deps/node/src/memory_tracker-inl.h @@ -178,7 +178,9 @@ void MemoryTracker::TrackField(const char* edge_name, const T& value, const char* node_name) { // For numbers, creating new nodes is not worth the overhead. - CurrentNode()->size_ += sizeof(T); + if (CurrentNode() != nullptr) { + CurrentNode()->size_ += sizeof(T); + } } template diff --git a/src/lwnode/lwnode-loader.cc b/src/lwnode/lwnode-loader.cc index 5eaedbf0e0..505b5ea8d1 100644 --- a/src/lwnode/lwnode-loader.cc +++ b/src/lwnode/lwnode-loader.cc @@ -65,7 +65,12 @@ bool convertUTF8ToUTF16le(char** buffer, size_t utf16Size = utf16.size() * 2; - *buffer = (char*)allocateStringBuffer(utf16Size + 1); + void* allocatedStringBuffer = allocateStringBuffer(utf16Size + 1); + if (allocatedStringBuffer == NULL) { + return false; + } + + *buffer = static_cast(allocatedStringBuffer); memcpy(*buffer, utf16.data(), utf16Size); (*buffer)[utf16Size] = '\0';