From 0b79a737324a398de15976d258b27cf4597b9d29 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 1 Sep 2014 17:24:18 -0400 Subject: [PATCH] crash fix if composer is opened in a topic that was deleted/purged --- src/socket.io/modules.js | 4 ++++ src/topics/posts.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/socket.io/modules.js b/src/socket.io/modules.js index 45fde242dd..1156b1c379 100644 --- a/src/socket.io/modules.js +++ b/src/socket.io/modules.js @@ -71,6 +71,10 @@ SocketModules.composer.push = function(socket, pid, callback) { return callback(err); } + if (!results.topic) { + return callback(new Error('[[error:no-topic]]')); + } + callback(null, { pid: pid, body: postData.content, diff --git a/src/topics/posts.js b/src/topics/posts.js index 98c712341a..b6dc910005 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -248,6 +248,9 @@ module.exports = function(Topics) { Topics.getTopicDataByPid = function(pid, callback) { posts.getPostField(pid, 'tid', function(err, tid) { + if (err) { + return callback(err); + } Topics.getTopicData(tid, callback); }); };