From aec79f3a794a1f54b712c19f125c6a63cb3d5ac4 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 21 Feb 2020 17:26:29 +0100 Subject: [PATCH] don't assume verify has been called when receiving a cancellation in verifier --- src/crypto/verification/Base.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/crypto/verification/Base.js b/src/crypto/verification/Base.js index c319bb1883b..d139839494d 100644 --- a/src/crypto/verification/Base.js +++ b/src/crypto/verification/Base.js @@ -155,10 +155,13 @@ export class VerificationBase extends EventEmitter { } else if (e.getType() === "m.key.verification.cancel") { const reject = this._reject; this._reject = undefined; - const content = e.getContent(); - const {reason, code} = content; - reject(new Error(`Other side cancelled verification ` + - `because ${reason} (${code})`)); + // there is only promise to reject if verify has been called + if (reject) { + const content = e.getContent(); + const {reason, code} = content; + reject(new Error(`Other side cancelled verification ` + + `because ${reason} (${code})`)); + } } else if (this._expectedEvent) { // only cancel if there is an event expected. // if there is no event expected, it means verify() wasn't called