fix rdp crashing in fullscreen and not 100% viewport #7587

Signed-off-by: si458 <simonsmith5521@gmail.com>

si458 committed Jan 29, 2026 at 21:42 UTC f9c22a9acd09780641dd4b5959b13735a2930a3f
1 file changed +9 -1
rdp/core/type.js
+9 -1
@@ -303,7 +303,15 @@ inherits(SingleType, Type);
303 * @param s
304 */
305 SingleType.prototype.writeValue = function(s) {
306 - this.writeBufferCallback.call(s.buffer, this.value, s.offset);
306 + var safeValue = this.value;
307 + if (typeof safeValue === 'number') { // FIX: Sanitize coordinates to prevent crashes
308 + safeValue = Math.round(safeValue); // Round to nearest integer (fixes -1.01 issues)
309 + if (safeValue < 0) safeValue = 0; // Clamp to 0 if negative
310 + // nbBytes is 1 (UInt8), 2 (UInt16), or 4 (UInt32)
311 + var max = Math.pow(2, this.nbBytes * 8) - 1;
312 + if (safeValue > max) safeValue = max; // Clamp to max value allowed by the buffer size (prevents overflow crashes)
313 + }
314 + this.writeBufferCallback.call(s.buffer, safeValue, s.offset);
315 s.offset += this._size_();
316 };
317