Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit c4cbee1

Browse files
committed
[ CID 118225 ] Fix potential uninitialised memory error
1 parent 08eb496 commit c4cbee1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

libbrowser/src/libbrowser_value.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,10 +663,12 @@ class MCBrowserDictionary : public MCBrowserRefCounted
663663
if (p_size <= m_capacity)
664664
return true;
665665

666-
uindex_t t_capacity;
667-
if (MCBrowserMemoryResizeArray(p_size, m_elements, t_capacity) && MCBrowserMemoryResizeArray(p_size, m_keys, t_capacity))
666+
uindex_t t_element_capacity, t_key_capacity;
667+
// Need to pass original capacity to BOTH calls to MCBrowserMemoryResizeArray, to ensure memory is appropriately cleared.
668+
t_element_capacity = t_key_capacity = m_capacity;
669+
if (MCBrowserMemoryResizeArray(p_size, m_elements, t_element_capacity) && MCBrowserMemoryResizeArray(p_size, m_keys, t_key_capacity))
668670
{
669-
m_capacity = t_capacity;
671+
m_capacity = t_element_capacity;
670672
return true;
671673
}
672674

0 commit comments

Comments
 (0)