From 078efc4042971a43fadb12613205a797727cf87d Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 3 Nov 2011 12:46:48 -0400 Subject: [PATCH] Don't die if a creator is missing at an index --- chrome/content/zotero/xpcom/itemTreeView.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 2e442ac1b7..a312e5fa4a 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -1266,6 +1266,15 @@ Zotero.ItemTreeView.prototype.sort = function(itemID) aPos++; var aFound = false; while (aPos < aNumCreators) { + // Don't die if there's no creator at an index + if (!aCreators[aPos]) { + Components.utils.reportError( + "Creator is missing at position " + aPos + + " for item " + a.ref.libraryID + "/" + a.ref.key + ); + return -1; + } + if (aCreators[aPos].creatorTypeID == aFirstCreatorTypeID) { aFound = true; break; @@ -1276,6 +1285,15 @@ Zotero.ItemTreeView.prototype.sort = function(itemID) bPos++; var bFound = false; while (bPos < bNumCreators) { + // Don't die if there's no creator at an index + if (!bCreators[bPos]) { + Components.utils.reportError( + "Creator is missing at position " + bPos + + " for item " + b.ref.libraryID + "/" + b.ref.key + ); + return -1; + } + if (bCreators[bPos].creatorTypeID == bFirstCreatorTypeID) { bFound = true; break;