Просмотр исходного кода

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

Yuxiao Mao 2 месяцев назад
Родитель
Сommit
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 {
 	function __expand(req:Int):Void {
-		var nsize = (size * 3) >> 1;
+		var nsize = (size * 3) >>> 1;
 		if (nsize < req)
 		if (nsize < req)
 			nsize = req;
 			nsize = req;
+		if (nsize < pos)
+			throw "Can't expand " + (size >> 10) + "K";
 		var b2 = new hl.Bytes(nsize);
 		var b2 = new hl.Bytes(nsize);
 		b2.blit(0, b, 0, pos);
 		b2.blit(0, b, 0, pos);
 		b = b2;
 		b = b2;