From 8d6dcc6b074fa03c933efc04d7afc8cd59aa0451 Mon Sep 17 00:00:00 2001 From: Hu Haolong Date: Thu, 12 Jun 2025 13:12:08 +0800 Subject: [PATCH] sys_authority.go: Fix a potential nil pointer dereference in GetParentAuthorityID (#2044) --- server/service/system/sys_authority.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/service/system/sys_authority.go b/server/service/system/sys_authority.go index e5a5fcbf..66805e48 100644 --- a/server/service/system/sys_authority.go +++ b/server/service/system/sys_authority.go @@ -326,5 +326,8 @@ func (authorityService *AuthorityService) findChildrenAuthority(authority *syste func (authorityService *AuthorityService) GetParentAuthorityID(authorityID uint) (parentID uint, err error) { var authority system.SysAuthority err = global.GVA_DB.Where("authority_id = ?", authorityID).First(&authority).Error - return *authority.ParentId, err + if err != nil { + return + } + return *authority.ParentId, nil }