Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 166c7217 authored by Sean McQuillan's avatar Sean McQuillan
Browse files

Don't crash after unsetting char[] in TextView

TextView.setText(char[]) is from API 1 and follows a running with
scissors API style of not copying the passed array.

To avoid a leak, in TextView.setText(String), the char[] would be nulled
out. However, an internal object could have been read using .getText()
prior to this second setText would immmediatly become a
CharSequence that crashed when you called any methods on it.

After this change, the CharWrapper will stay valid if had been
previously retrieved. The general shape of the API will be maintained.

Fixes: b/227218386
Test: atest android.widget.TextViewTest
Relnote: "Calling TextView.getText() after calling TextView.setText(char[])
will now return a valid CharSequence. The char[] pointed to by this char
sequnece may still be mutated by future calls to setText(char[]), but it
will no longer allow a (char[]) null to be set, which lead to crashes
when reading CharSequence returned from getText on TextView."

Change-Id: I35a2a76d58ec1946dace2f615cacf6a6085efdeb
parent bfd0db18
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment