From ba2a8e07a4b76fb8792531b071de582a14a6dbe4 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 10 Apr 2025 16:00:39 -0400 Subject: [PATCH] LibWeb: Store WritableStream's strategy high water mark as a double It is received from user JS as a double and is only used as a double in all subsequent calculations. This bug would cause UBSAN errors in an upcoming imported WPT test, which passes Infinity as the HWM. Note there is an equivalent HWM for ReadableStream, which already stores the value as a double. --- Libraries/LibWeb/Streams/WritableStreamDefaultController.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Libraries/LibWeb/Streams/WritableStreamDefaultController.h b/Libraries/LibWeb/Streams/WritableStreamDefaultController.h index 5a0fa8fafb4..4ffc70f3663 100644 --- a/Libraries/LibWeb/Streams/WritableStreamDefaultController.h +++ b/Libraries/LibWeb/Streams/WritableStreamDefaultController.h @@ -38,8 +38,8 @@ public: bool started() const { return m_started; } void set_started(bool value) { m_started = value; } - size_t strategy_hwm() const { return m_strategy_hwm; } - void set_strategy_hwm(size_t value) { m_strategy_hwm = value; } + double strategy_hwm() const { return m_strategy_hwm; } + void set_strategy_hwm(double value) { m_strategy_hwm = value; } GC::Ptr strategy_size_algorithm() { return m_strategy_size_algorithm; } void set_strategy_size_algorithm(GC::Ptr value) { m_strategy_size_algorithm = value; } @@ -86,7 +86,7 @@ private: // https://streams.spec.whatwg.org/#writablestreamdefaultcontroller-strategyhwm // A number supplied by the creator of the stream as part of the stream’s queuing strategy, indicating the point at which the stream will apply backpressure to its underlying sink - size_t m_strategy_hwm { 0 }; + double m_strategy_hwm { 0 }; // https://streams.spec.whatwg.org/#writablestreamdefaultcontroller-strategysizealgorithm // An algorithm to calculate the size of enqueued chunks, as part of the stream’s queuing strategy