Skip to content

Commit b653802

Browse files
committed
Avoid null pointer arithmetic in SplFixedArray
Fixes bug62904.phpt under clang ubsan.
1 parent 52cf7ab commit b653802

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ext/spl/spl_fixedarray.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ static void spl_fixedarray_copy_ctor(spl_fixedarray *to, spl_fixedarray *from)
134134
{
135135
zend_long size = from->size;
136136
spl_fixedarray_init(to, size);
137-
138-
zval *begin = from->elements, *end = from->elements + size;
139-
spl_fixedarray_copy_range(to, 0, begin, end);
137+
if (size != 0) {
138+
zval *begin = from->elements, *end = from->elements + size;
139+
spl_fixedarray_copy_range(to, 0, begin, end);
140+
}
140141
}
141142

142143
/* Destructs the elements in the range [from, to).

0 commit comments

Comments
 (0)