Selaa lähdekoodia

fixed int32 overflow on php and python

Nicolas Cannasse 10 vuotta sitten
vanhempi
commit
b6deed80e4
1 muutettua tiedostoa jossa 3 lisäystä ja 0 poistoa
  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