From f2c7caf2db7468430915b8892e5316fc9cfdc52a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 1 Dec 2020 17:06:48 +0100 Subject: [PATCH] LibJS: Zero out memory in newly allocated Uint8ClampedArray objects --- Libraries/LibJS/Runtime/Uint8ClampedArray.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Libraries/LibJS/Runtime/Uint8ClampedArray.cpp b/Libraries/LibJS/Runtime/Uint8ClampedArray.cpp index 5683e7f646..bd9b6e5367 100644 --- a/Libraries/LibJS/Runtime/Uint8ClampedArray.cpp +++ b/Libraries/LibJS/Runtime/Uint8ClampedArray.cpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace JS { @@ -42,13 +43,13 @@ Uint8ClampedArray::Uint8ClampedArray(u32 length, Object& prototype) { auto& vm = this->vm(); define_native_property(vm.names.length, length_getter, nullptr); - m_data = new u8[m_length]; + m_data = (u8*)calloc(m_length, 1); } Uint8ClampedArray::~Uint8ClampedArray() { ASSERT(m_data); - delete[] m_data; + free(m_data); m_data = nullptr; }