From f5faf8618021fb73a756eae09e0ecb693ac5d7de Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 29 Apr 2025 11:17:38 +0200 Subject: [PATCH] Assert that `numberToString` is called with a number (issue 19877) *NOTE:* Given that this is an *internal* function, used only in the worker-thread, it's not clear to me that this is an entirely "necessary" change. --- src/core/core_utils.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/core_utils.js b/src/core/core_utils.js index b23072d59..eef79cddd 100644 --- a/src/core/core_utils.js +++ b/src/core/core_utils.js @@ -632,6 +632,13 @@ function recoverJsURL(str) { } function numberToString(value) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { + assert( + typeof value === "number", + `numberToString - the value (${value}) should be a number.` + ); + } + if (Number.isInteger(value)) { return value.toString(); }