From 2023f55f321b8244e50299b11acb7c0d2788a4f0 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 18 Jun 2019 08:24:17 +0300 Subject: [PATCH] Recover from panics in event handlers --- go.mod | 7 +++---- go.sum | 11 +++++++++++ portal.go | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 5b0d9ef..28c3897 100644 --- a/go.mod +++ b/go.mod @@ -7,16 +7,15 @@ require ( github.com/lib/pq v1.1.1 github.com/mattn/go-sqlite3 v1.10.0 github.com/pkg/errors v0.8.1 - github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9 gopkg.in/yaml.v2 v2.2.2 maunium.net/go/mauflag v1.0.0 maunium.net/go/maulogger/v2 v2.0.0 - maunium.net/go/mautrix v0.1.0-alpha.3.0.20190601171344-255a8ab0cdce - maunium.net/go/mautrix-appservice v0.1.0-alpha.3.0.20190601171457-3e042283fbf8 + maunium.net/go/mautrix v0.1.0-alpha.3.0.20190606153009-ca5d9535b6cc + maunium.net/go/mautrix-appservice v0.1.0-alpha.3.0.20190618052224-6e6c9bb47548 ) replace ( - github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.0.2-0.20190616200017-be3e82b27b44 + github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.0.2-0.20190618052157-36ed380bdc18 gopkg.in/russross/blackfriday.v2 => github.com/russross/blackfriday/v2 v2.0.1 ) diff --git a/go.sum b/go.sum index 8c336c7..84b8a59 100644 --- a/go.sum +++ b/go.sum @@ -30,17 +30,24 @@ github.com/tulir/go-whatsapp v0.0.2-0.20190616195837-d26c9b29e792 h1:k49pIXr5hYb github.com/tulir/go-whatsapp v0.0.2-0.20190616195837-d26c9b29e792/go.mod h1:u3Hdptbz3iB5y/NEoSKgsp9hBzUlm0A5OrLMVdENAX8= github.com/tulir/go-whatsapp v0.0.2-0.20190616200017-be3e82b27b44 h1:YQPydpctgrbXaS8WZA8yVSOewStey7kW7eOnlESbSwo= github.com/tulir/go-whatsapp v0.0.2-0.20190616200017-be3e82b27b44/go.mod h1:u3Hdptbz3iB5y/NEoSKgsp9hBzUlm0A5OrLMVdENAX8= +github.com/tulir/go-whatsapp v0.0.2-0.20190618052157-36ed380bdc18 h1:Qs7QvR6McwqOLWgY4+L+HV81TSJtlE0YN4wZ4u/AgXY= +github.com/tulir/go-whatsapp v0.0.2-0.20190618052157-36ed380bdc18/go.mod h1:u3Hdptbz3iB5y/NEoSKgsp9hBzUlm0A5OrLMVdENAX8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65 h1:+rhAzEzT3f4JtomfC371qB+0Ola2caSKcY69NUBZrRQ= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190606122018-79a91cf218c4 h1:3i7qG/aA9NUAzdnJHfhgxSKSmxbAebomYR5IZgFbC5Y= +golang.org/x/sys v0.0.0-20190606122018-79a91cf218c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M= @@ -49,5 +56,9 @@ maunium.net/go/maulogger/v2 v2.0.0 h1:8PB95zf6e7Ddw8iOWqjrJjAjPcAI50LagA1X0Ur64o maunium.net/go/maulogger/v2 v2.0.0/go.mod h1:Hbbkq3NV6jvJodByZu1mgEF3fpT7Kz9z0MjEZ3/BusI= maunium.net/go/mautrix v0.1.0-alpha.3.0.20190601171344-255a8ab0cdce h1:9Q1wEmlV6ABYn2opIrX8Ukg29yWYQ1mkd2zcj/K6Xxc= maunium.net/go/mautrix v0.1.0-alpha.3.0.20190601171344-255a8ab0cdce/go.mod h1:2YZIxbevlhzCkqJDVbPOuE+h7muO4rfJbJcy5V601SM= +maunium.net/go/mautrix v0.1.0-alpha.3.0.20190606153009-ca5d9535b6cc h1:G7Nse6r/XaCu+p7yc/3m/nfFuOFZZ87Hb3AOX4INOEk= +maunium.net/go/mautrix v0.1.0-alpha.3.0.20190606153009-ca5d9535b6cc/go.mod h1:O+QWJP3H7BZEzIBSrECKpnpRnEKBwaoWVEu/yZwVwxg= maunium.net/go/mautrix-appservice v0.1.0-alpha.3.0.20190601171457-3e042283fbf8 h1:c917bxSojo44tQqxazKJ5NIoZ4tDOiLG4GWok7jPFTg= maunium.net/go/mautrix-appservice v0.1.0-alpha.3.0.20190601171457-3e042283fbf8/go.mod h1:JVzc+BlwFORpdrDqdpjfFDCdU3+hO9Oa5hucGxyIUp8= +maunium.net/go/mautrix-appservice v0.1.0-alpha.3.0.20190618052224-6e6c9bb47548 h1:ni1nqs+2AOO+g1ND6f2W0pMcb6sIDVqzerXosO+pI2g= +maunium.net/go/mautrix-appservice v0.1.0-alpha.3.0.20190618052224-6e6c9bb47548/go.mod h1:yVWU0gvIHIXClgyVnShiufiDksFbFrBqHG9lDAYcmGI= diff --git a/portal.go b/portal.go index 03075f2..5351429 100644 --- a/portal.go +++ b/portal.go @@ -1198,7 +1198,7 @@ func (portal *Portal) HandleMatrixRedaction(sender *User, evt *mautrix.Event) { } msg := portal.bridge.DB.Message.GetByMXID(evt.Redacts) - if msg.Sender != sender.JID { + if msg == nil || msg.Sender != sender.JID { return }