diff options
| author | Peter Eliasson <peter.eliasson.x@sonyericsson.com> | 2010-04-26 12:32:40 +0200 |
|---|---|---|
| committer | Johan Redestig <johan.redestig@sonyericsson.com> | 2010-04-26 12:32:40 +0200 |
| commit | 417675cab0f8f2fb73ff067071b5347186a81c19 (patch) | |
| tree | 8ac66b9c7420b646edae790a1b268ff9e99cc2e3 /graphics/java | |
| parent | 5a870fee53ca94c7575503c72574ca0f068d52c7 (diff) | |
| download | frameworks_base-417675cab0f8f2fb73ff067071b5347186a81c19.zip frameworks_base-417675cab0f8f2fb73ff067071b5347186a81c19.tar.gz frameworks_base-417675cab0f8f2fb73ff067071b5347186a81c19.tar.bz2 | |
Improved error handling when font loading fails.
Without this patch, an application could trigger a platform crash
by calling:
Typeface typeface = Typeface.createFromFile("");
boolean isbold = typeface.isBold();
The crash occurs since the Skia error that occurs when font loading
fails is not propagated.
With this patch, the Typeface constructor throws an
IllegalStateException when Skia fails to load the font (i.e. when
the native instance is null).
Change-Id: I1002b37b7b32840cb7eeef6819d2982cb18c9003
Diffstat (limited to 'graphics/java')
| -rw-r--r-- | graphics/java/android/graphics/Typeface.java | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java index f0d5a6a..9a404f4 100644 --- a/graphics/java/android/graphics/Typeface.java +++ b/graphics/java/android/graphics/Typeface.java @@ -143,6 +143,9 @@ public class Typeface { // don't allow clients to call this directly private Typeface(int ni) { + if (ni == 0) { + throw new IllegalStateException(); + } native_instance = ni; } |
