From d0d2e56dad6441b74ae25d2523f6537ae4a9dd71 Mon Sep 17 00:00:00 2001 From: laiguizhong Date: Mon, 25 Jul 2022 01:41:56 -0700 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3SystemGetParameterCommitId?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3fuzzy=E6=B5=8B=E8=AF=95=E4=BC=9A=E5=BC=95?= =?UTF-8?q?=E8=B5=B7sigbus=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laiguizhong Change-Id: I81dbe3f13087e280c60a1e6c8b4e825e0c09de3d --- services/param/base/param_comm.c | 5 ++++- services/param/include/param_utils.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/param/base/param_comm.c b/services/param/base/param_comm.c index d183355ce..75c8cbcfa 100644 --- a/services/param/base/param_comm.c +++ b/services/param/base/param_comm.c @@ -72,7 +72,10 @@ INIT_LOCAL_API ParamTrieNode *GetTrieNodeByHandle(ParamHandle handle) WorkSpace *workSpace = HASHMAP_ENTRY(node, WorkSpace, hashNode); WORKSPACE_RW_UNLOCK(*paramSpace); index = index - workSpace->area->startIndex; - return (ParamTrieNode *)GetTrieNode(workSpace, index); + if (PARAM_IS_ALIGNED(index)) { + return (ParamTrieNode *)GetTrieNode(workSpace, index); + } + return NULL; } INIT_LOCAL_API WorkSpace *GetFirstWorkSpace(void) diff --git a/services/param/include/param_utils.h b/services/param/include/param_utils.h index fcd2f17bb..0e40a9cb9 100644 --- a/services/param/include/param_utils.h +++ b/services/param/include/param_utils.h @@ -49,6 +49,7 @@ typedef struct cmdLineInfo { #define UNUSED(x) (void)(x) #endif #define PARAM_ALIGN(len) (((len) + 0x03) & (~0x03)) +#define PARAM_IS_ALIGNED(x) (((x) & 0x03) == 0) #define PARAM_ENTRY(ptr, type, member) (type *)((char *)(ptr)-offsetof(type, member)) #define IS_READY_ONLY(name) \