Skip to content

Node.js based forum software built for the modern web

crash fix

barisusaklieab180f30534
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);