Skip to content

Commit 4826dfc

Browse files
committed
bug-fix: SVGAPath may cause crash due to invalid float conversion.
1 parent f3e7612 commit 4826dfc

File tree

1 file changed

+7
-3
lines changed
  • library/src/main/java/com/opensource/svgaplayer

1 file changed

+7
-3
lines changed

library/src/main/java/com/opensource/svgaplayer/SVGAPath.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,20 @@ internal class SVGAPath {
2929
}
3030
val firstLetter = item.substring(0, 1)
3131
if (VALID_METHODS.contains(firstLetter)) {
32-
if (null != argLast) {
33-
args.add(SVGAPoint(0.0f, 0.0f, argLast.toFloat()))
32+
argLast?.takeIf { it.isNotEmpty() }?.let {
33+
args.add(SVGAPoint(0.0f, 0.0f, try {it.toFloat()} catch (e: Exception) { 0.0f }))
3434
}
3535
this.operate(finalPath, currentMethod, args)
3636
args.clear()
3737
currentMethod = firstLetter
3838
argLast = item.substring(1)
3939
} else {
4040
if (null != argLast && argLast.trim { it <= ' ' }.length > 0) {
41-
args.add(SVGAPoint(argLast.toFloat(), item.toFloat(), 0.0f))
41+
args.add(SVGAPoint(try {
42+
argLast.toFloat()
43+
} catch (e: Exception) {0.0f}, try {
44+
item.toFloat()
45+
} catch (e: Exception) {0.0f}, 0.0f))
4246
argLast = null
4347
} else {
4448
argLast = item

0 commit comments

Comments
 (0)