OSDN Git Service

Fix NPE in Html.inParagraph()
authorRaph Levien <raph@google.com>
Tue, 5 May 2015 17:13:54 +0000 (10:13 -0700)
committerRaph Levien <raph@google.com>
Tue, 5 May 2015 17:13:54 +0000 (10:13 -0700)
The typeface in a TypefaceSpan can be the null string. This patch
fixes the string comparison to not throw a NullPointerException.

Bug: 20849738
Change-Id: Ied049305794966bcbca00cfd11fe97a91b685d79

core/java/android/text/Html.java

index 7bebbfb..a55a08c 100644 (file)
@@ -278,7 +278,7 @@ public class Html {
                 if (style[j] instanceof TypefaceSpan) {
                     String s = ((TypefaceSpan) style[j]).getFamily();
 
-                    if (s.equals("monospace")) {
+                    if ("monospace".equals(s)) {
                         out.append("<tt>");
                     }
                 }