diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js index 83e15e6df..5d26f470c 100644 --- a/src/node/db/Pad.js +++ b/src/node/db/Pad.js @@ -188,7 +188,12 @@ Pad.prototype.getInternalRevisionAText = function getInternalRevisionAText(targe db.getSub("pad:"+_this.id+":revs:"+keyRev, ["meta", "atext"], function(err, _atext) { if(ERR(err, callback)) return; - atext = Changeset.cloneAText(_atext); + try { + atext = Changeset.cloneAText(_atext); + } catch (e) { + return callback(e); + } + callback(); }); }, diff --git a/src/static/js/Changeset.js b/src/static/js/Changeset.js index 04a055147..6f6e7d099 100644 --- a/src/static/js/Changeset.js +++ b/src/static/js/Changeset.js @@ -1628,10 +1628,12 @@ exports.applyToAText = function (cs, atext, pool) { * @param atext {AText} */ exports.cloneAText = function (atext) { - return { - text: atext.text, - attribs: atext.attribs - }; + if (atext) { + return { + text: atext.text, + attribs: atext.attribs + } + } else exports.error("atext is null"); }; /**