Fix server side bug index overflow

The server wasn't properly checking that the changesets it needed to
return for changeset_requests actually existed.
This commit is contained in:
s1341 2013-12-16 17:32:32 +02:00
parent 6f6a86faa6
commit 5add63165d

View file

@ -1281,6 +1281,7 @@ function getChangesetInfo(padId, startNum, endNum, granularity, callback)
var composedChangesets = {};
var revisionDate = [];
var lines;
var head_revision = 0;
async.series([
//get the pad from the database
@ -1290,6 +1291,7 @@ function getChangesetInfo(padId, startNum, endNum, granularity, callback)
{
if(ERR(err, callback)) return;
pad = _pad;
head_revision = pad.getHeadRevisionNumber();
callback();
});
},
@ -1369,13 +1371,12 @@ function getChangesetInfo(padId, startNum, endNum, granularity, callback)
while (compositeStart < endNum)
{
if (compositeStart + granularity > endNum)
var compositeEnd = compositeStart + granularity;
if (compositeEnd > endNum || compositeEnd > head_revision)
{
break;
}
var compositeEnd = compositeStart + granularity;
var forwards = composedChangesets[compositeStart + "/" + compositeEnd];
var backwards = Changeset.inverse(forwards, lines.textlines, lines.alines, pad.apool());
@ -1479,7 +1480,7 @@ function getPadLines(padId, revNum, callback)
function composePadChangesets(padId, startNum, endNum, callback)
{
var pad;
var changesets = [];
var changesets = {};
var changeset;
async.series([
@ -1498,6 +1499,11 @@ function composePadChangesets(padId, startNum, endNum, callback)
{
var changesetsNeeded=[];
var headNum = pad.getHeadRevisionNumber();
if (endNum > headNum)
endNum = headNum;
if (startNum < 0)
startNum = 0;
//create a array for all changesets, we will
//replace the values with the changeset later
for(var r=startNum;r<endNum;r++)