From fc42b4c5b10ee141964edf5bd917cbeb6f755f11 Mon Sep 17 00:00:00 2001 From: panchengzhong <1144372483@qq.com> Date: Fri, 10 Feb 2023 11:19:17 +0800 Subject: [PATCH] alloc buffer with zero Signed-off-by: panchengzhong <1144372483@qq.com> --- .../libs/distributeddb/communicator/src/serial_buffer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/serial_buffer.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/serial_buffer.cpp index 934ea3ec..24065e78 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/serial_buffer.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/serial_buffer.cpp @@ -55,7 +55,7 @@ int SerialBuffer::AllocBufferByPayloadLength(uint32_t inPayloadLen, uint32_t inH if (totalLen_ == 0 || totalLen_ > MAX_TOTAL_LEN) { return -E_INVALID_ARGS; } - oringinalBytes_ = new (std::nothrow) uint8_t[totalLen_ + extendHeadLen_]; + oringinalBytes_ = new (std::nothrow) uint8_t[totalLen_ + extendHeadLen_](); if (oringinalBytes_ == nullptr) { return -E_OUT_OF_MEMORY; } @@ -77,7 +77,7 @@ int SerialBuffer::AllocBufferByTotalLength(uint32_t inTotalLen, uint32_t inHeade headerLen_ = inHeaderLen; payloadLen_ = totalLen_ - headerLen_; paddingLen_ = 0; - bytes_ = new (std::nothrow) uint8_t[inTotalLen]; + bytes_ = new (std::nothrow) uint8_t[inTotalLen](); if (bytes_ == nullptr) { return -E_OUT_OF_MEMORY; } -- Gitee