From d1f0dd6ade844225d20437e6d2d8e8a546e4a893 Mon Sep 17 00:00:00 2001 From: wujianlin Date: Tue, 21 Jan 2025 10:19:09 +0800 Subject: [PATCH] add nullptr check when read from parcel Issue:https://gitee.com/openharmony/commonlibrary_c_utils/issues/IBJ1DO?from=project-issue Signed-off-by: wujianlin --- base/src/parcel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/base/src/parcel.cpp b/base/src/parcel.cpp index 09bb4aa..27d3d37 100644 --- a/base/src/parcel.cpp +++ b/base/src/parcel.cpp @@ -776,6 +776,10 @@ bool Parcel::Read(T &value) size_t desireCapacity = sizeof(T); if (desireCapacity <= GetReadableBytes()) { + if (data_ == nullptr) { + UTILS_LOGE("data_ is nullptr when parcel is being read."); + return false; + } const void *data = data_ + readCursor_; #ifdef PARCEL_OBJECT_CHECK size_t upperBound = readCursor_ + desireCapacity; -- Gitee