summaryrefslogtreecommitdiff
path: root/AK/ByteBuffer.h
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-05-14 09:22:01 +0430
committerLinus Groh <mail@linusgroh.de>2021-05-14 08:39:29 +0100
commitbfd4c7a16cd35452bc5d1331f05d8bd713b37d14 (patch)
treef0ac73a80819a7ca3baaee37e1eb509cdcecd8b2 /AK/ByteBuffer.h
parenta4e20a87d5e66b06ca39bdcc0d4dd5c273a9eb46 (diff)
downloadserenity-bfd4c7a16cd35452bc5d1331f05d8bd713b37d14.zip
AK: Avoid passing nullptr to __buitin_memcpy() in ByteBuffer::grow()
Diffstat (limited to 'AK/ByteBuffer.h')
-rw-r--r--AK/ByteBuffer.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h
index 38e1e377f9..a308782638 100644
--- a/AK/ByteBuffer.h
+++ b/AK/ByteBuffer.h
@@ -277,7 +277,8 @@ inline void ByteBufferImpl::grow(size_t size)
return;
}
u8* new_data = static_cast<u8*>(kmalloc(size));
- __builtin_memcpy(new_data, m_data, m_size);
+ if (m_data)
+ __builtin_memcpy(new_data, m_data, m_size);
u8* old_data = m_data;
m_data = new_data;
m_size = size;