mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-18 10:50:23 +00:00
7107013: sun.jvm.hotspot.runtime.Bytes.swapLong conversion to long mishandled
Cast to long to avoid truncation in swapLong() Reviewed-by: dsamersoff
This commit is contained in:
parent
7d9d3aa1a0
commit
7c690441e4
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -51,7 +51,7 @@ public class Bytes {
|
||||
if (!swap)
|
||||
return x;
|
||||
|
||||
return (swapShort((short) x) << 16) | (swapShort((short) (x >> 16)) & 0xFFFF);
|
||||
return ((int)swapShort((short) x) << 16) | (swapShort((short) (x >> 16)) & 0xFFFF);
|
||||
}
|
||||
|
||||
/** Should only swap if the hardware's underlying byte order is
|
||||
@ -60,6 +60,6 @@ public class Bytes {
|
||||
if (!swap)
|
||||
return x;
|
||||
|
||||
return (swapInt((int) x) << 32) | (swapInt((int) (x >> 32)) & 0xFFFFFFFF);
|
||||
return ((long)swapInt((int) x) << 32) | (swapInt((int) (x >> 32)) & 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user