[GTK] Safeguard against possible NULL-dereference
https://bugs.webkit.org/show_bug.cgi?id=104931

Patch by Claudio Saavedra <csaavedra@igalia.com> on 2013-01-16
Reviewed by Martin Robinson.

* accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
(webkitAccessibleGetIndexInParent): Move the NULL-safeguard to a
place where it actually makes sense.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@139890 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp b/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp
index f284b25..e46c86d 100644
--- a/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp
+++ b/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp
@@ -407,9 +407,6 @@
     AccessibilityObject* coreObject = core(object);
     AccessibilityObject* parent = coreObject->parentObjectUnignored();
 
-    if (!parent)
-        return -1;
-
     if (!parent && isRootObject(coreObject)) {
         AtkObject* atkParent = atkParentOfRootObject(object);
         if (!atkParent)
@@ -430,6 +427,9 @@
     if (parent && parent->isTableRow() && coreObject->isTableCell())
         return getIndexInParentForCellInRow(coreObject);
 
+    if (!parent)
+        return -1;
+
     size_t index = parent->children().find(coreObject);
     return (index == WTF::notFound) ? -1 : index;
 }