From eab180f30534d6d411734d0f84446484e6f18f44 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 2 Oct 2014 19:03:03 -0400 Subject: [PATCH] crash fix --- src/posts.js | 4 +++- src/privileges/posts.js | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/posts.js b/src/posts.js index 6d6089f732..dad45bc196 100644 --- a/src/posts.js +++ b/src/posts.js @@ -379,7 +379,9 @@ var async = require('async'), }; Posts.getPostsFields = function(pids, fields, callback) { - pids = pids ? pids : []; + if (!Array.isArray(pids) || !pids.length) { + return callback(null, []); + } var keys = pids.map(function(pid) { return 'post:' + pid; diff --git a/src/privileges/posts.js b/src/privileges/posts.js index 9cf41f4864..ca3999898d 100644 --- a/src/privileges/posts.js +++ b/src/privileges/posts.js @@ -16,6 +16,9 @@ module.exports = function(privileges) { privileges.posts = {}; privileges.posts.get = function(pids, uid, callback) { + if (!Array.isArray(pids) || !pids.length) { + return callback(null, []); + } async.parallel({ manage_content: function(next) { helpers.hasEnoughReputationFor('privileges:manage_content', uid, next);