From 9c2d2180e62acbdfa08d7f1592c73205cea1b61d Mon Sep 17 00:00:00 2001 From: Ibrahim Serdar Acikgoz Date: Tue, 15 Sep 2020 15:25:12 +0300 Subject: [PATCH] store/channel_store_categories: fix index out of bounds error (#15423) --- store/sqlstore/channel_store_categories.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/store/sqlstore/channel_store_categories.go b/store/sqlstore/channel_store_categories.go index 6ac421f267..4987add8f0 100644 --- a/store/sqlstore/channel_store_categories.go +++ b/store/sqlstore/channel_store_categories.go @@ -415,6 +415,9 @@ func (s SqlChannelStore) GetSidebarCategory(categoryId string) (*model.SidebarCa if _, err := s.GetReplica().Select(&categories, sql, args...); err != nil { return nil, model.NewAppError("SqlPostStore.GetSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, err.Error(), http.StatusNotFound) } + if len(categories) == 0 { + return nil, model.NewAppError("SqlPostStore.GetSidebarCategory", "store.sql_channel.sidebar_categories.app_error", nil, "", http.StatusNotFound) + } result := &model.SidebarCategoryWithChannels{ SidebarCategory: categories[0].SidebarCategory, Channels: make([]string, 0),