Index: ui/gfx/render_text_pango.cc |
diff --git a/ui/gfx/render_text_pango.cc b/ui/gfx/render_text_pango.cc |
index 9db3995fcee95a34c2b9b6a6b132c7c9ad8b3df7..b3a84fa523236468f32d02abbb9e4974757e32eb 100644 |
--- a/ui/gfx/render_text_pango.cc |
+++ b/ui/gfx/render_text_pango.cc |
@@ -82,6 +82,15 @@ Size RenderTextPango::GetStringSize() { |
EnsureLayout(); |
int width = 0, height = 0; |
pango_layout_get_pixel_size(layout_, &width, &height); |
+ |
+ // Pango returns 0 widths for very long strings (of 0x40000 chars or more). |
+ // This is caused by an int overflow in pango_glyph_string_extents_range. |
+ // Absurdly long strings may even report non-zero garbage values for width; |
+ // while detecting that isn't worthwhile, this handles the 0 width cases. |
+ const long kAbsurdLength = 100000; |
+ if (width == 0 && g_utf8_strlen(layout_text_, -1) > kAbsurdLength) |
+ width = font_list().GetExpectedTextWidth(g_utf8_strlen(layout_text_, -1)); |
+ |
// Keep a consistent height between this particular string's PangoLayout and |
// potentially larger text supported by the FontList. |
// For example, if a text field contains a Japanese character, which is |