Skip to content

Commit 7e8039e

Browse files
committed
Arbitrarily limit array_pad() to only do 1 million elements at a time.
Probably still too high, but it solves the segfault for now.
1 parent d1c0cc7 commit 7e8039e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

TODO_SEGFAULTS

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ Fixed:
88
socket_iovec_alloc (Rasmus)
99
exif_imagetype,exif_thumbnail (Rasmus)
1010
dbase_open (Rasmus)
11-
11+
array_pad (Rasmus)
1212

1313
Open:
1414

15-
array_pad
1615
bcsub (1)
1716
mb_ereg (2)
1817
mb_ereg_match (2)

ext/standard/array.c

+4
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,10 @@ PHP_FUNCTION(array_pad)
23392339

23402340
/* Populate the pads array */
23412341
num_pads = pad_size_abs - input_size;
2342+
if(num_pads > 1048576) {
2343+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "You may only pad up to 1048576 elements at a time");
2344+
RETURN_FALSE;
2345+
}
23422346
pads = (zval ***)emalloc(num_pads * sizeof(zval **));
23432347
for (i = 0; i < num_pads; i++)
23442348
pads[i] = pad_value;

0 commit comments

Comments
 (0)