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.
This commit is contained in:
Timothy Flynn 2025-04-10 16:00:39 -04:00
commit ba2a8e07a4

View file

@ -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<SizeAlgorithm> strategy_size_algorithm() { return m_strategy_size_algorithm; }
void set_strategy_size_algorithm(GC::Ptr<SizeAlgorithm> 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 streams 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 streams queuing strategy