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.
  • Loading branch information
vanniktech committed Aug 5, 2024
1 parent 1f77b78 commit 6caf73f
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,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 @@ -566,6 +566,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);
FileOutputStream fos = new FileOutputStream(tempFile);
try {
Expand Down

0 comments on commit 6caf73f

Please sign in to comment.