From 1d7656184c6b8aa46b29149893894b3c24f1df00 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sat, 20 May 2023 02:57:59 +0530 Subject: [jsinterp] Handle `NaN` in bitwise operators Closes #6131 --- yt_dlp/jsinterp.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'yt_dlp/jsinterp.py') diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.py index 5571ecfeb..965b1c0f2 100644 --- a/yt_dlp/jsinterp.py +++ b/yt_dlp/jsinterp.py @@ -20,7 +20,12 @@ from .utils import ( def _js_bit_op(op): def zeroise(x): - return 0 if x in (None, JS_Undefined) else x + if x in (None, JS_Undefined): + return 0 + with contextlib.suppress(TypeError): + if math.isnan(x): # NB: NaN cannot be checked by membership + return 0 + return x def wrapped(a, b): return op(zeroise(a), zeroise(b)) & 0xffffffff -- cgit v1.2.3