From 9d87188e6cfae177c6f1e87c003cd01077131092 Mon Sep 17 00:00:00 2001 From: panchengzhong <1144372483@qq.com> Date: Fri, 10 Feb 2023 11:22:50 +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 92cce786..8109c640 100755 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/serial_buffer.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/serial_buffer.cpp @@ -43,7 +43,7 @@ int SerialBuffer::AllocBufferByPayloadLength(uint32_t inPayloadLen, uint32_t inH if (totalLen_ == 0 || totalLen_ > MAX_TOTAL_LEN) { return -E_INVALID_ARGS; } - bytes_ = new (std::nothrow) uint8_t[totalLen_]; + bytes_ = new (std::nothrow) uint8_t[totalLen_](); if (bytes_ == nullptr) { return -E_OUT_OF_MEMORY; } @@ -64,7 +64,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