From 43cae72ad9d4bf1c8b18aea483e47ddc152b656f Mon Sep 17 00:00:00 2001 From: chenkeyu Date: Tue, 3 Sep 2024 09:26:01 +0800 Subject: [PATCH] add nullptr check when write to parcel Issue: https://gitee.com/openharmony/commonlibrary_c_utils/issues/IAOBNZ?from=project-issue Signed-off-by: chenkeyu --- base/src/parcel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/base/src/parcel.cpp b/base/src/parcel.cpp index 64fcfc8..b6edcfc 100644 --- a/base/src/parcel.cpp +++ b/base/src/parcel.cpp @@ -126,6 +126,10 @@ bool Parcel::EnsureWritableCapacity(size_t desireCapacity) return false; } if (desireCapacity <= GetWritableBytes()) { + if (data_ == nullptr) { + UTILS_LOGE("data_ is nullptr when capacity is available"); + return false; + } return true; } -- Gitee