浏览代码

fixed int32 overflow on php and python

Nicolas Cannasse 10 年之前
父节点
当前提交
b6deed80e4
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      std/haxe/io/Bytes.hx

+ 3 - 0
std/haxe/io/Bytes.hx

@@ -298,6 +298,9 @@ class Bytes {
 	public inline function getInt32( pos : Int ) : Int {
 		#if neko_v21
 		return untyped $sget32(b, pos, false);
+		#elseif (php || python)
+		var v = get(pos) | (get(pos + 1) << 8) | (get(pos + 2) << 16) | (get(pos+3) << 24);
+        return if( v & 0x80000000 != 0 ) v | 0x80000000 else v;
 		#else
 		return get(pos) | (get(pos + 1) << 8) | (get(pos + 2) << 16) | (get(pos+3) << 24);
 		#end