Skip to content

Commit

Permalink
LottieCompositionFactory: Avoid NPE when animation contains a Font Fa…
Browse files Browse the repository at this point in the history
…mily and Context is null. (#2530)
  • Loading branch information
vanniktech committed Aug 5, 2024
1 parent a52e6d0 commit 1ffaac8
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ public static LottieResult<LottieComposition> fromZipStreamSync(@Nullable Contex
}

@WorkerThread
private static LottieResult<LottieComposition> fromZipStreamSyncInternal(Context context, ZipInputStream inputStream, @Nullable String cacheKey) {
private static LottieResult<LottieComposition> fromZipStreamSyncInternal(@Nullable Context context, ZipInputStream inputStream, @Nullable String cacheKey) {
LottieComposition composition = null;
Map<String, Bitmap> images = new HashMap<>();
Map<String, Typeface> fonts = new HashMap<>();
Expand Down Expand Up @@ -581,6 +581,11 @@ private static LottieResult<LottieComposition> fromZipStreamSyncInternal(Context
String[] splitName = entryName.split("/");
String fileName = splitName[splitName.length - 1];
String fontFamily = fileName.split("\\.")[0];

if (context == null) {
return new LottieResult<>(new IllegalStateException("Unable to extract font " + fontFamily + " please pass a non-null Context parameter"));
}

File tempFile = new File(context.getCacheDir(), fileName);
try (FileOutputStream fos = new FileOutputStream(tempFile)) {
try (OutputStream output = new FileOutputStream(tempFile)) {
Expand Down

0 comments on commit 1ffaac8

Please sign in to comment.