Skip to content

fix: don't pass a non-positive pinch scale to math.log - #2241

Open
AzazelSensei wants to merge 1 commit into
fleaflet:masterfrom
AzazelSensei:fix/pinch-non-positive-scale
Open

fix: don't pass a non-positive pinch scale to math.log#2241
AzazelSensei wants to merge 1 commit into
fleaflet:masterfrom
AzazelSensei:fix/pinch-non-positive-scale

Conversation

@AzazelSensei

Copy link
Copy Markdown

Fixes #2237

The pinch-zoom path only checked details.scale > 0 before calling math.log. The value that actually gets logged is details.scale + _scaleCorrector. After a multi-finger gesture race win, that corrector is 1 - lastScale, so the sum can be 0 or negative. log of that is NaN, and it goes straight into the camera.

I now check the corrected scale at the call site. zoomForScale also keeps the start zoom if the scale isn't a positive finite number, so the other two callers are covered too.

There's a unit test with the numbers from the issue (lastScale = 2.5, new gesture at details.scale = 1.0).

The pinch path checked details.scale > 0, but the value actually
logged is details.scale + _scaleCorrector. After a gesture-race
win that corrector is 1 - lastScale, so the sum can go <= 0.
math.log of that is NaN and it ends up in the camera.

Skip the zoom update for that frame, and make zoomForScale return
the start zoom when the scale isn't usable.

Fixes fleaflet#2237
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pinch zoom can pass a non-positive scale to math.log, poisoning the camera with NaN

1 participant