Skip to content

Commit

Permalink
Safety checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-rosso committed Sep 4, 2019
1 parent 2c078c1 commit 2bf6b43
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions flare_dart/lib/animation/actor_animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "../stream_reader.dart";
import "keyframe.dart";
import "property_types.dart";


typedef KeyFrame KeyFrameReader(StreamReader reader, ActorComponent component);

class PropertyAnimation {
Expand Down Expand Up @@ -228,6 +227,7 @@ class ComponentAnimation {
int numProperties = reader.readUint16Length();
componentAnimation._properties = List<PropertyAnimation>(numProperties);
for (int i = 0; i < numProperties; i++) {
assert(componentAnimation._componentIndex < components.length);
componentAnimation._properties[i] = PropertyAnimation.read(
reader, components[componentAnimation._componentIndex]);
}
Expand Down Expand Up @@ -396,8 +396,8 @@ class ActorAnimation {
int numKeyedComponents = reader.readUint16Length();

// We distinguish between animated and triggered components as ActorEvents
// are currently only used to trigger events and don't need the full
// animation cycle. This lets them optimize them out of the regular
// are currently only used to trigger events and don't need the full
// animation cycle. This lets them optimize them out of the regular
// animation cycle.
int animatedComponentCount = 0;
int triggerComponentCount = 0;
Expand All @@ -408,7 +408,8 @@ class ActorAnimation {
ComponentAnimation componentAnimation =
ComponentAnimation.read(reader, components);
animatedComponents[i] = componentAnimation;
if (componentAnimation != null) {
if (componentAnimation != null &&
componentAnimation.componentIndex < components.length) {
ActorComponent actorComponent =
components[componentAnimation.componentIndex];
if (actorComponent != null) {
Expand Down

0 comments on commit 2bf6b43

Please sign in to comment.