Bug 1308908 - Compare the whole accessible name when checking equality. r=tbsaunde
authorColomban Wendling <cwendling@hypra.fr>
Fri, 27 Jan 2017 09:36:00 -0500
changeset 372942 13d5c32e4a61b1fec4669b80aefb801a9e5cb968
parent 372941 96b7a3ed364bab98ace2bdc9a0d4a57ee55d6121
child 372943 92de31554a9f5c5da8bc36fa06b85e215a45220f
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs1308908
milestone54.0a1
Bug 1308908 - Compare the whole accessible name when checking equality. r=tbsaunde Use strcmp() instead of strncmp() when comparing the AtkObject name before changing it. 9133117f410c06ad7fa25323a168bc97200043b9 changed from Equals() to strncmp() to prevent issues related to embedded NUL bytes, but the change lead to only checking if the AtkObject name has the new value as prefix. Instead, use strcmp() to check the whole C strings, but still stopping at the first NUL byte in the new name. strcmp() has to be safe here, as NS_ConvertUTF16toUTF8::get() has to return a NUL-terminated string or the code would crash a few lines below when calling strdup() on it.
accessible/atk/AccessibleWrap.cpp
--- a/accessible/atk/AccessibleWrap.cpp
+++ b/accessible/atk/AccessibleWrap.cpp
@@ -609,18 +609,17 @@ getNameCB(AtkObject* aAtkObj)
 
   return aAtkObj->name;
 }
 
 static void
 MaybeFireNameChange(AtkObject* aAtkObj, const nsString& aNewName)
 {
   NS_ConvertUTF16toUTF8 newNameUTF8(aNewName);
-  if (aAtkObj->name &&
-      !strncmp(aAtkObj->name, newNameUTF8.get(), newNameUTF8.Length()))
+  if (aAtkObj->name && !strcmp(aAtkObj->name, newNameUTF8.get()))
     return;
 
   // Below we duplicate the functionality of atk_object_set_name(),
   // but without calling atk_object_get_name(). Instead of
   // atk_object_get_name() we directly access aAtkObj->name. This is because
   // atk_object_get_name() would call getNameCB() which would call
   // MaybeFireNameChange() (or atk_object_set_name() before this problem was
   // fixed) and we would get an infinite recursion.