Jelajahi Sumber

throw error when trying to call readBytes with pos > 0 on not seekable stream, closes #3445

frabbit 10 tahun lalu
induk
melakukan
1fc64612c0
1 mengubah file dengan 3 tambahan dan 0 penghapusan
  1. 3 0
      std/python/io/NativeInput.hx

+ 3 - 0
std/python/io/NativeInput.hx

@@ -58,8 +58,11 @@ class NativeInput<T:IOBase> extends Input{
 		if( pos < 0 || len < 0 || pos + len > s.length )
 			throw haxe.io.Error.OutsideBounds;
 
+
 		if (canSeek) {
 			seek(pos, SeekBegin);
+		} else if (pos > 0) {
+			throw "Cannot call readBytes for pos > 0 (" + pos + ") on not seekable stream";
 		}
 		var ba = new Bytearray(len);
 		var ret = readinto(ba);