Skip to content

Commit 0e22e5f

Browse files
authored
Initialize _clippedViewPort to avoid null deref on first render (#1148)
_clippedViewPort is declared but never initialized, unlike its sibling _previousViewPort. It is only assigned inside updateClippedViewPort(), which updateViewPort() skips calling whenever _viewPort already equals the default-empty _previousViewPort — which can be true on the very first frame depending on how the initial viewport is set up. When that happens, render() dereferences _clippedViewPort.width/height while it is still null. Found while porting a unit test suite to openfl/starling (the Haxe port carries the identical gap), and confirmed here in the original AS3 source.
1 parent 94e73d3 commit 0e22e5f

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

starling/src/starling/core/Starling.as

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ package starling.core
280280
_rootClass = rootClass;
281281
_viewPort = viewPort;
282282
_previousViewPort = new Rectangle();
283+
_clippedViewPort = new Rectangle();
283284
_stage = new Stage(viewPort.width, viewPort.height, stage.color);
284285
_nativeOverlay = new Sprite();
285286
_nativeStage = stage;

0 commit comments

Comments
 (0)