diff --git a/services/utils/data_buffer.cpp b/services/utils/data_buffer.cpp index df809e253b3a75512922b0bbf09fd31d9534fbde..ceec3807a1c852f18d612b66ddad9d7d70c52d5a 100755 --- a/services/utils/data_buffer.cpp +++ b/services/utils/data_buffer.cpp @@ -96,9 +96,13 @@ void DataBuffer::Resize(int size) if (data_ && size_ > 0) { auto ret = memcpy_s(data2, capacity_, data_, size_); if (ret != EOK) { + delete[] data2; return; } + } + if (data_) { delete[] data_; + data_ = nullptr; } data_ = data2; } else if (size < capacity_) {