Skip to content

Commit 2d66993

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix undefined behavior (left shift of negative number)
2 parents e4c52e6 + 48df7da commit 2d66993

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/standard/image.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -749,10 +749,10 @@ static signed short php_ifd_get16s(void *Short, int motorola_intel)
749749
static int php_ifd_get32s(void *Long, int motorola_intel)
750750
{
751751
if (motorola_intel) {
752-
return ((( char *)Long)[0] << 24) | (((unsigned char *)Long)[1] << 16)
753-
| (((unsigned char *)Long)[2] << 8 ) | (((unsigned char *)Long)[3] << 0 );
752+
return ((unsigned)((( char *)Long)[0]) << 24) | (((unsigned char *)Long)[1] << 16)
753+
| ((( char *)Long)[2] << 8 ) | (((unsigned char *)Long)[3] << 0 );
754754
} else {
755-
return ((( char *)Long)[3] << 24) | (((unsigned char *)Long)[2] << 16)
755+
return ((unsigned)((( char *)Long)[3]) << 24) | (((unsigned char *)Long)[2] << 16)
756756
| (((unsigned char *)Long)[1] << 8 ) | (((unsigned char *)Long)[0] << 0 );
757757
}
758758
}

0 commit comments

Comments
 (0)