Skip to content

Commit 8d6dcc6

Browse files
authored
sys_authority.go: Fix a potential nil pointer dereference in GetParentAuthorityID (#2044)
1 parent e3a57bd commit 8d6dcc6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

server/service/system/sys_authority.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,5 +326,8 @@ func (authorityService *AuthorityService) findChildrenAuthority(authority *syste
326326
func (authorityService *AuthorityService) GetParentAuthorityID(authorityID uint) (parentID uint, err error) {
327327
var authority system.SysAuthority
328328
err = global.GVA_DB.Where("authority_id = ?", authorityID).First(&authority).Error
329-
return *authority.ParentId, err
329+
if err != nil {
330+
return
331+
}
332+
return *authority.ParentId, nil
330333
}

0 commit comments

Comments
 (0)