From 6ecefebcd1d016c5f56b01ddfd06db822fcc15bc Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Wed, 16 Aug 2017 14:12:37 +0100 Subject: [PATCH] Add a check on type --- .../dendrite/publicroomsapi/storage/public_rooms_table.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/publicroomsapi/storage/public_rooms_table.go b/src/github.com/matrix-org/dendrite/publicroomsapi/storage/public_rooms_table.go index 6ebeeb315..a5b275902 100644 --- a/src/github.com/matrix-org/dendrite/publicroomsapi/storage/public_rooms_table.go +++ b/src/github.com/matrix-org/dendrite/publicroomsapi/storage/public_rooms_table.go @@ -226,10 +226,12 @@ func (s *publicRoomsStatements) updateRoomAttribute(attrName string, attrValue a var value interface{} if attrName == "aliases" { // Aliases need a special conversion - if value, err = pq.StringArray(attrValue.([]string)); err != nil { + valueAsSlice, isSlice := attrValue.([]string) + if !isSlice { // attrValue isn't a slice of strings - return err + return errors.New("New list of aliases is of the wrong type") } + value = pq.StringArray(valueAsSlice) } else { value = attrValue }