From 5b8b515b06ba33a1c733198221ed85ad59b4b9c9 Mon Sep 17 00:00:00 2001
From: Simon Kornblith <simon@simonster.com>
Date: Thu, 2 Feb 2012 03:07:26 -0500
Subject: [PATCH] Fix potential crash activating integration dialog on Linux

---
 chrome/content/zotero/xpcom/integration.js | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js
index fc2af10417..adccd624ba 100644
--- a/chrome/content/zotero/xpcom/integration.js
+++ b/chrome/content/zotero/xpcom/integration.js
@@ -564,8 +564,9 @@ Zotero.Integration = new function() {
 		var children = ctypes.cast(childrenPtr, ctypes.uint32_t.array(nChildrenJS).ptr).contents;
 		var foundWindow = false;
 		for(var i=0; i<nChildrenJS; i++) {
-			foundWindow = _X11FindWindow(display, children.addressOfElement(i).contents,
-				searchName);
+			var testWin = children.addressOfElement(i).contents;
+			if(testWin == 0) continue;
+			foundWindow = _X11FindWindow(display, testWin, searchName);
 			if(foundWindow) break;
 		}
 		
@@ -2997,4 +2998,4 @@ Zotero.Integration.URIMap.prototype.getZoteroItemForURIs = function(uris) {
 	}
 	
 	return [zoteroItem, needUpdate];
-}
\ No newline at end of file
+}