[java-atk-wrapper] Check pointer before dereferencing it



commit d33c0f6b95d1f9580dc93835a6f0089fe71a2c0f
Author: Samuel Thibault <samuel thibault ens-lyon org>
Date:   Mon Mar 14 00:08:10 2022 +0100

    Check pointer before dereferencing it

 jni/src/jawimpl.c                              | 2 +-
 wrapper/org/GNOME/Accessibility/AtkAction.java | 4 +++-
 wrapper/org/GNOME/Accessibility/AtkTable.java  | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/jni/src/jawimpl.c b/jni/src/jawimpl.c
index 145b269..9c8d552 100644
--- a/jni/src/jawimpl.c
+++ b/jni/src/jawimpl.c
@@ -568,7 +568,7 @@ jaw_impl_get_interface_data (JawObject *jaw_obj, guint iface)
   JAW_DEBUG_C("%p, %u", jaw_obj, iface);
   JawImpl *jaw_impl = (JawImpl*)jaw_obj;
 
-  if (jaw_impl->ifaceTable == NULL || jaw_impl == NULL)
+  if (jaw_impl == NULL || jaw_impl->ifaceTable == NULL)
     return NULL;
 
   JawInterfaceInfo *info = g_hash_table_lookup(jaw_impl->ifaceTable,GUINT_TO_POINTER(iface));
diff --git a/wrapper/org/GNOME/Accessibility/AtkAction.java b/wrapper/org/GNOME/Accessibility/AtkAction.java
index 1d01e70..0ba1bdc 100644
--- a/wrapper/org/GNOME/Accessibility/AtkAction.java
+++ b/wrapper/org/GNOME/Accessibility/AtkAction.java
@@ -137,10 +137,12 @@ public class AtkAction {
        }
 
        public String get_keybinding (int index) {
-               AccessibleExtendedComponent acc_ext_component = _acc_ext_component.get();
+               AccessibleExtendedComponent acc_ext_component;
                if (_acc_ext_component == null)
                        return "";
 
+               acc_ext_component = _acc_ext_component.get();
+
                // TODO: improve/fix conversion to strings, concatenate,
                //       and follow our formatting convention for the role of
                //       various keybindings (i.e. global, transient, etc.)
diff --git a/wrapper/org/GNOME/Accessibility/AtkTable.java b/wrapper/org/GNOME/Accessibility/AtkTable.java
index 58ff9ae..a885b10 100644
--- a/wrapper/org/GNOME/Accessibility/AtkTable.java
+++ b/wrapper/org/GNOME/Accessibility/AtkTable.java
@@ -180,7 +180,7 @@ public class AtkTable {
 
                AtkUtil.invokeInSwing( () -> {
                        Accessible accessible = acc_table.getAccessibleColumnDescription(column);
-                       if (description.equals(accessible.toString()) && accessible != null)
+                       if (accessible != null && description.equals(accessible.toString()))
                                acc_table.setAccessibleColumnDescription(column, accessible);
                });
        }
@@ -214,7 +214,7 @@ public class AtkTable {
 
                AtkUtil.invokeInSwing( () -> {
                        Accessible accessible = acc_table.getAccessibleRowDescription(row);
-                       if (description.equals(accessible.toString()) && accessible != null)
+                       if (accessible != null && description.equals(accessible.toString()))
                                acc_table.setAccessibleRowDescription(row, accessible);
                });
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]