瀏覽代碼

[std] hl haxe.io.BytesBuffer.__expand check overflow (#12267)

Yuxiao Mao 1 月之前
父節點
當前提交
a9dbe27958
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      std/hl/_std/haxe/io/BytesBuffer.hx

+ 3 - 1
std/hl/_std/haxe/io/BytesBuffer.hx

@@ -47,9 +47,11 @@ class BytesBuffer {
 	}
 
 	function __expand(req:Int):Void {
-		var nsize = (size * 3) >> 1;
+		var nsize = (size * 3) >>> 1;
 		if (nsize < req)
 			nsize = req;
+		if (nsize < pos)
+			throw "Can't expand " + (size >> 10) + "K";
 		var b2 = new hl.Bytes(nsize);
 		b2.blit(0, b, 0, pos);
 		b = b2;