Skip to content

Commit

Permalink
fix: resolve static analysis defects
Browse files Browse the repository at this point in the history
Signed-off-by: Hosung Kim [email protected]
  • Loading branch information
hs0225 committed Mar 7, 2024
1 parent 778ac34 commit 8b0d0b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion deps/node/src/memory_tracker-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T, typename U>
Expand Down
7 changes: 6 additions & 1 deletion src/lwnode/lwnode-loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<char*>(allocatedStringBuffer);
memcpy(*buffer, utf16.data(), utf16Size);
(*buffer)[utf16Size] = '\0';

Expand Down

0 comments on commit 8b0d0b4

Please sign in to comment.