From c6ca343cd1b198c6a15f8d3045bc7e83b1a36cf3 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 16 Jun 2019 21:24:51 +0300 Subject: [PATCH] Fix panic in redaction handling --- matrix/history.go | 2 +- matrix/matrix.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/matrix/history.go b/matrix/history.go index af81ed2..bcec304 100644 --- a/matrix/history.go +++ b/matrix/history.go @@ -123,7 +123,7 @@ func (hm *HistoryManager) Update(room *rooms.Room, eventID string, update func(e } stream := tx.Bucket(bucketRoomStreams).Bucket(rid) eventData := stream.Get(streamIndex) - if eventData == nil { + if eventData == nil || len(eventData) == 0 { return EventNotFoundError } diff --git a/matrix/matrix.go b/matrix/matrix.go index 9178ca0..6c2809c 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -321,7 +321,7 @@ func (c *Container) HandleRedaction(source EventSource, evt *mautrix.Event) { debug.Print("Failed to mark", evt.Redacts, "as redacted:", err) } - if !room.Loaded() { + if !room.Loaded() || redactedEvt == nil { return }