Permalink
Browse files

preventing crash caused by invalid Array size during indent calculation

  • Loading branch information...
1 parent 31df4c5 commit 898f4f5bd9929774aa4f36465f4f54ef9bcabf73 @thlorenz thlorenz committed Apr 6, 2013
Showing with 9 additions and 3 deletions.
  1. +9 −3 index.js
View
@@ -84,9 +84,15 @@ function difflet (opts, prev, next) {
}
var inserted = insertable && prevNode === undefined;
- var indentx = indent ? Array(
- ((this.path || []).length + 1) * indent + 1
- ).join(' ') : '';
+ var indentx;
+ try {
+ indentx = indent ? Array(
+ ((this.path || []).length + 1) * indent + 1
+ ).join(' ') : '';
+ } catch (e) {
+ // at times we get an invalid Array size here and need to prevent crashing
+ indentx = '';
+ }
if (commaFirst) indentx = indentx.slice(indent);
if (Array.isArray(node)) {

0 comments on commit 898f4f5

Please sign in to comment.