Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
Bug 1884300 - Add NullPointerException for SvgIconDecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzy823 authored and mergify[bot] committed Mar 8, 2024
1 parent 8d184f3 commit e8c1dac
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import mozilla.components.support.images.decoder.ImageDecoder
class SvgIconDecoder(val context: Context) : ImageDecoder {
private val logger = Logger("SvgIconDecoder")

@Suppress("TooGenericExceptionCaught")
override fun decode(data: ByteArray, desiredSize: DesiredSize): Bitmap? =
try {
val svg = SVG.getFromInputStream(data.inputStream())
Expand Down Expand Up @@ -65,6 +66,9 @@ class SvgIconDecoder(val context: Context) : ImageDecoder {
svg.renderToCanvas(Canvas(bitmap))

bitmap
} catch (e: NullPointerException) {
logger.error("Failed to decode SVG: " + e.message.toString())
null
} catch (e: IllegalArgumentException) {
logger.error("Failed to decode SVG: " + e.message.toString())
null
Expand Down

0 comments on commit e8c1dac

Please sign in to comment.