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.
This commit is contained in:
Colomban Wendling
2017-01-27 09:36:00 -05:00
parent f3641970ce
commit f16034535e

View File

@@ -614,8 +614,7 @@ 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(),