From: Iskren Chernev Date: Sun, 28 Dec 2014 16:51:46 +0000 (+0200) Subject: Make sure updateOffset on creation won't cause infinite recursion X-Git-Tag: 2.9.0~12^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbf42711479a9009a671513e22a97023360e380a;p=thirdparty%2Fmoment.git Make sure updateOffset on creation won't cause infinite recursion --- diff --git a/moment.js b/moment.js index 3507addac..bc476c38b 100644 --- a/moment.js +++ b/moment.js @@ -285,7 +285,9 @@ deprecations = {}, - lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin']; + lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'], + + updateInProgress = false; // Pick the first defined of two or three arguments. dfl comes from // default. @@ -404,8 +406,12 @@ } copyConfig(this, config); this._d = new Date(+config._d); - if (moment.updateOffset) { + // Prevent infinite loop in case updateOffset creates new moment + // objects. + if (updateInProgress === false) { + updateInProgress = true; moment.updateOffset(this); + updateInProgress = false; } }