Skip to content

Commit 325a113

Browse files
committed
Possible fix for bug #77287
The cache size could be off by 4, if we're on a 32-bit system and the slot had to be bumped for alignment reasons. I wasn't able to reproduce the issue reported in bug #77287, but I think this might be the cause.
1 parent 2915891 commit 325a113

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/opcache/Optimizer/compact_literals.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,9 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
805805
zval *val = &op_array->literals[opline->op2.constant];
806806

807807
if (Z_TYPE_P(val) == IS_CONSTANT_AST) {
808-
uint32_t slot = ZEND_MM_ALIGNED_SIZE_EX(op_array->cache_size, 8);
809-
810-
Z_CACHE_SLOT_P(val) = slot;
808+
/* Ensure zval is aligned to 8 bytes */
809+
op_array->cache_size = ZEND_MM_ALIGNED_SIZE_EX(op_array->cache_size, 8);
810+
Z_CACHE_SLOT_P(val) = op_array->cache_size;
811811
op_array->cache_size += sizeof(zval);
812812
}
813813
} else if (opline->opcode != ZEND_RECV) {

0 commit comments

Comments
 (0)