Skip to content

Commit ecb4234

Browse files
committed
8373447: Suspicious sign extension after integer promotion in imageDecompressor.cpp
Reviewed-by: alanb
1 parent 4b8eda3 commit ecb4234

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/java.base/share/native/libjimage/imageDecompressor.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -111,21 +111,21 @@ ImageDecompressor* ImageDecompressor::get_decompressor(const char * decompressor
111111
u8 ImageDecompressor::getU8(u1* ptr, Endian *endian) {
112112
u8 ret;
113113
if (endian->is_big_endian()) {
114-
ret = (u8)ptr[0] << 56 | (u8)ptr[1] << 48 | (u8)ptr[2]<<40 | (u8)ptr[3]<<32 |
115-
ptr[4]<<24 | ptr[5]<<16 | ptr[6]<<8 | ptr[7];
114+
ret = (u8)ptr[0] << 56 | (u8)ptr[1] << 48 | (u8)ptr[2] << 40 | (u8)ptr[3] << 32 |
115+
(u8)ptr[4] << 24 | (u8)ptr[5] << 16 | (u8)ptr[6] << 8 | (u8)ptr[7];
116116
} else {
117-
ret = ptr[0] | ptr[1]<<8 | ptr[2]<<16 | ptr[3]<<24 | (u8)ptr[4]<<32 |
118-
(u8)ptr[5]<<40 | (u8)ptr[6]<<48 | (u8)ptr[7]<<56;
117+
ret = (u8)ptr[0] | (u8)ptr[1] << 8 | (u8)ptr[2] << 16 | (u8)ptr[3] << 24 |
118+
(u8)ptr[4] << 32 | (u8)ptr[5] << 40 | (u8)ptr[6] << 48 | (u8)ptr[7] << 56;
119119
}
120120
return ret;
121121
}
122122

123123
u4 ImageDecompressor::getU4(u1* ptr, Endian *endian) {
124124
u4 ret;
125125
if (endian->is_big_endian()) {
126-
ret = ptr[0] << 24 | ptr[1]<<16 | (ptr[2]<<8) | ptr[3];
126+
ret = (u4)ptr[0] << 24 | (u4)ptr[1] << 16 | (u4)ptr[2] << 8 | (u4)ptr[3];
127127
} else {
128-
ret = ptr[0] | ptr[1]<<8 | (ptr[2]<<16) | ptr[3]<<24;
128+
ret = (u4)ptr[0] | (u4)ptr[1] << 8 | (u4)ptr[2] << 16 | (u4)ptr[3] << 24;
129129
}
130130
return ret;
131131
}

0 commit comments

Comments
 (0)