Skip to content

Commit 2616c46

Browse files
committed
[#17035] - updating ext
1 parent 544d38f commit 2616c46

1,241 files changed

Lines changed: 50705 additions & 17555 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ext/config.m4

Lines changed: 485 additions & 47 deletions
Large diffs are not rendered by default.

ext/config.w32

Lines changed: 90 additions & 42 deletions
Large diffs are not rendered by default.

ext/kernel/concat.c

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,10 @@ void zephir_concat_sssvsvsvsvsvs(zval *result, const char *op1, uint32_t op1_len
302302

303303
}
304304

305-
void zephir_concat_ssv(zval *result, const char *op1, uint32_t op1_len, const char *op2, uint32_t op2_len, zval *op3, int self_var){
305+
void zephir_concat_ssvsvs(zval *result, const char *op1, uint32_t op1_len, const char *op2, uint32_t op2_len, zval *op3, const char *op4, uint32_t op4_len, zval *op5, const char *op6, uint32_t op6_len, int self_var){
306306

307-
zval result_copy, op3_copy;
308-
int use_copy = 0, use_copy3 = 0;
307+
zval result_copy, op3_copy, op5_copy;
308+
int use_copy = 0, use_copy3 = 0, use_copy5 = 0;
309309
size_t offset = 0, length;
310310

311311
if (Z_TYPE_P(op3) != IS_STRING) {
@@ -315,7 +315,14 @@ void zephir_concat_ssv(zval *result, const char *op1, uint32_t op1_len, const ch
315315
}
316316
}
317317

318-
length = op1_len + op2_len + Z_STRLEN_P(op3);
318+
if (Z_TYPE_P(op5) != IS_STRING) {
319+
use_copy5 = zend_make_printable_zval(op5, &op5_copy);
320+
if (use_copy5) {
321+
op5 = &op5_copy;
322+
}
323+
}
324+
325+
length = op1_len + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len;
319326
if (self_var) {
320327

321328
if (Z_TYPE_P(result) != IS_STRING) {
@@ -336,22 +343,29 @@ void zephir_concat_ssv(zval *result, const char *op1, uint32_t op1_len, const ch
336343
memcpy(Z_STRVAL_P(result) + offset, op1, op1_len);
337344
memcpy(Z_STRVAL_P(result) + offset + op1_len, op2, op2_len);
338345
memcpy(Z_STRVAL_P(result) + offset + op1_len + op2_len, Z_STRVAL_P(op3), Z_STRLEN_P(op3));
346+
memcpy(Z_STRVAL_P(result) + offset + op1_len + op2_len + Z_STRLEN_P(op3), op4, op4_len);
347+
memcpy(Z_STRVAL_P(result) + offset + op1_len + op2_len + Z_STRLEN_P(op3) + op4_len, Z_STRVAL_P(op5), Z_STRLEN_P(op5));
348+
memcpy(Z_STRVAL_P(result) + offset + op1_len + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5), op6, op6_len);
339349
Z_STRVAL_P(result)[length] = 0;
340350
zend_string_forget_hash_val(Z_STR_P(result));
341351
if (use_copy3) {
342352
zval_dtor(op3);
343353
}
344354

355+
if (use_copy5) {
356+
zval_dtor(op5);
357+
}
358+
345359
if (use_copy) {
346360
zval_dtor(&result_copy);
347361
}
348362

349363
}
350364

351-
void zephir_concat_ssvsvs(zval *result, const char *op1, uint32_t op1_len, const char *op2, uint32_t op2_len, zval *op3, const char *op4, uint32_t op4_len, zval *op5, const char *op6, uint32_t op6_len, int self_var){
365+
void zephir_concat_ssvsvsv(zval *result, const char *op1, uint32_t op1_len, const char *op2, uint32_t op2_len, zval *op3, const char *op4, uint32_t op4_len, zval *op5, const char *op6, uint32_t op6_len, zval *op7, int self_var){
352366

353-
zval result_copy, op3_copy, op5_copy;
354-
int use_copy = 0, use_copy3 = 0, use_copy5 = 0;
367+
zval result_copy, op3_copy, op5_copy, op7_copy;
368+
int use_copy = 0, use_copy3 = 0, use_copy5 = 0, use_copy7 = 0;
355369
size_t offset = 0, length;
356370

357371
if (Z_TYPE_P(op3) != IS_STRING) {
@@ -368,7 +382,14 @@ void zephir_concat_ssvsvs(zval *result, const char *op1, uint32_t op1_len, const
368382
}
369383
}
370384

371-
length = op1_len + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len;
385+
if (Z_TYPE_P(op7) != IS_STRING) {
386+
use_copy7 = zend_make_printable_zval(op7, &op7_copy);
387+
if (use_copy7) {
388+
op7 = &op7_copy;
389+
}
390+
}
391+
392+
length = op1_len + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len + Z_STRLEN_P(op7);
372393
if (self_var) {
373394

374395
if (Z_TYPE_P(result) != IS_STRING) {
@@ -392,6 +413,7 @@ void zephir_concat_ssvsvs(zval *result, const char *op1, uint32_t op1_len, const
392413
memcpy(Z_STRVAL_P(result) + offset + op1_len + op2_len + Z_STRLEN_P(op3), op4, op4_len);
393414
memcpy(Z_STRVAL_P(result) + offset + op1_len + op2_len + Z_STRLEN_P(op3) + op4_len, Z_STRVAL_P(op5), Z_STRLEN_P(op5));
394415
memcpy(Z_STRVAL_P(result) + offset + op1_len + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5), op6, op6_len);
416+
memcpy(Z_STRVAL_P(result) + offset + op1_len + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len, Z_STRVAL_P(op7), Z_STRLEN_P(op7));
395417
Z_STRVAL_P(result)[length] = 0;
396418
zend_string_forget_hash_val(Z_STR_P(result));
397419
if (use_copy3) {
@@ -402,6 +424,10 @@ void zephir_concat_ssvsvs(zval *result, const char *op1, uint32_t op1_len, const
402424
zval_dtor(op5);
403425
}
404426

427+
if (use_copy7) {
428+
zval_dtor(op7);
429+
}
430+
405431
if (use_copy) {
406432
zval_dtor(&result_copy);
407433
}

ext/kernel/concat.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424
#define ZEPHIR_SCONCAT_SSSVSVSVSVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8, op9, op10, op11, op12, op13) \
2525
zephir_concat_sssvsvsvsvsvs(result, op1, sizeof(op1)-1, op2, sizeof(op2)-1, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, op7, sizeof(op7)-1, op8, op9, sizeof(op9)-1, op10, op11, sizeof(op11)-1, op12, op13, sizeof(op13)-1, 1);
2626

27-
#define ZEPHIR_CONCAT_SSV(result, op1, op2, op3) \
28-
zephir_concat_ssv(result, op1, sizeof(op1)-1, op2, sizeof(op2)-1, op3, 0);
29-
#define ZEPHIR_SCONCAT_SSV(result, op1, op2, op3) \
30-
zephir_concat_ssv(result, op1, sizeof(op1)-1, op2, sizeof(op2)-1, op3, 1);
31-
3227
#define ZEPHIR_CONCAT_SSVSVS(result, op1, op2, op3, op4, op5, op6) \
3328
zephir_concat_ssvsvs(result, op1, sizeof(op1)-1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, 0);
3429
#define ZEPHIR_SCONCAT_SSVSVS(result, op1, op2, op3, op4, op5, op6) \
3530
zephir_concat_ssvsvs(result, op1, sizeof(op1)-1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, 1);
3631

32+
#define ZEPHIR_CONCAT_SSVSVSV(result, op1, op2, op3, op4, op5, op6, op7) \
33+
zephir_concat_ssvsvsv(result, op1, sizeof(op1)-1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, op7, 0);
34+
#define ZEPHIR_SCONCAT_SSVSVSV(result, op1, op2, op3, op4, op5, op6, op7) \
35+
zephir_concat_ssvsvsv(result, op1, sizeof(op1)-1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, op7, 1);
36+
3737
#define ZEPHIR_CONCAT_SSVSVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8) \
3838
zephir_concat_ssvsvsvs(result, op1, sizeof(op1)-1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, op7, op8, sizeof(op8)-1, 0);
3939
#define ZEPHIR_SCONCAT_SSVSVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8) \
@@ -219,8 +219,8 @@ void zephir_concat_ss(zval *result, const char *op1, uint32_t op1_len, const cha
219219
void zephir_concat_ssssssssssssssssssssssssssssssvssvss(zval *result, const char *op1, uint32_t op1_len, const char *op2, uint32_t op2_len, const char *op3, uint32_t op3_len, const char *op4, uint32_t op4_len, const char *op5, uint32_t op5_len, const char *op6, uint32_t op6_len, const char *op7, uint32_t op7_len, const char *op8, uint32_t op8_len, const char *op9, uint32_t op9_len, const char *op10, uint32_t op10_len, const char *op11, uint32_t op11_len, const char *op12, uint32_t op12_len, const char *op13, uint32_t op13_len, const char *op14, uint32_t op14_len, const char *op15, uint32_t op15_len, const char *op16, uint32_t op16_len, const char *op17, uint32_t op17_len, const char *op18, uint32_t op18_len, const char *op19, uint32_t op19_len, const char *op20, uint32_t op20_len, const char *op21, uint32_t op21_len, const char *op22, uint32_t op22_len, const char *op23, uint32_t op23_len, const char *op24, uint32_t op24_len, const char *op25, uint32_t op25_len, const char *op26, uint32_t op26_len, const char *op27, uint32_t op27_len, const char *op28, uint32_t op28_len, const char *op29, uint32_t op29_len, const char *op30, uint32_t op30_len, zval *op31, const char *op32, uint32_t op32_len, const char *op33, uint32_t op33_len, zval *op34, const char *op35, uint32_t op35_len, const char *op36, uint32_t op36_len, int self_var);
220220
void zephir_concat_ssssssssvssvss(zval *result, const char *op1, uint32_t op1_len, const char *op2, uint32_t op2_len, const char *op3, uint32_t op3_len, const char *op4, uint32_t op4_len, const char *op5, uint32_t op5_len, const char *op6, uint32_t op6_len, const char *op7, uint32_t op7_len, const char *op8, uint32_t op8_len, zval *op9, const char *op10, uint32_t op10_len, const char *op11, uint32_t op11_len, zval *op12, const char *op13, uint32_t op13_len, const char *op14, uint32_t op14_len, int self_var);
221221
void zephir_concat_sssvsvsvsvsvs(zval *result, const char *op1, uint32_t op1_len, const char *op2, uint32_t op2_len, const char *op3, uint32_t op3_len, zval *op4, const char *op5, uint32_t op5_len, zval *op6, const char *op7, uint32_t op7_len, zval *op8, const char *op9, uint32_t op9_len, zval *op10, const char *op11, uint32_t op11_len, zval *op12, const char *op13, uint32_t op13_len, int self_var);
222-
void zephir_concat_ssv(zval *result, const char *op1, uint32_t op1_len, const char *op2, uint32_t op2_len, zval *op3, int self_var);
223222
void zephir_concat_ssvsvs(zval *result, const char *op1, uint32_t op1_len, const char *op2, uint32_t op2_len, zval *op3, const char *op4, uint32_t op4_len, zval *op5, const char *op6, uint32_t op6_len, int self_var);
223+
void zephir_concat_ssvsvsv(zval *result, const char *op1, uint32_t op1_len, const char *op2, uint32_t op2_len, zval *op3, const char *op4, uint32_t op4_len, zval *op5, const char *op6, uint32_t op6_len, zval *op7, int self_var);
224224
void zephir_concat_ssvsvsvs(zval *result, const char *op1, uint32_t op1_len, const char *op2, uint32_t op2_len, zval *op3, const char *op4, uint32_t op4_len, zval *op5, const char *op6, uint32_t op6_len, zval *op7, const char *op8, uint32_t op8_len, int self_var);
225225
void zephir_concat_sv(zval *result, const char *op1, uint32_t op1_len, zval *op2, int self_var);
226226
void zephir_concat_svs(zval *result, const char *op1, uint32_t op1_len, zval *op2, const char *op3, uint32_t op3_len, int self_var);

ext/kernel/iterator.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,50 @@
2020
#include "kernel/memory.h"
2121

2222
/**
23-
* Returns an iterator from the object
23+
* Returns an iterator from the object.
24+
*
25+
* `iterator()` requires an object implementing Iterator or IteratorAggregate
26+
* (== Z_OBJCE_P(obj) has a non-NULL get_iterator handler). Passing anything
27+
* else — scalar, array, stdClass — used to return NULL silently and the
28+
* caller would NULL-deref on `it->funcs->rewind`, segfaulting the process.
29+
* Now we throw a TypeError matching PHP's own foreach diagnostic so user
30+
* code can catch and recover. See
31+
* https://github.com/zephir-lang/zephir/issues/820.
2432
*/
2533
zend_object_iterator *zephir_get_iterator(zval *iterator)
2634
{
2735
zend_class_entry *ce;
2836
zend_object_iterator *it;
2937

3038
if (UNEXPECTED(Z_TYPE_P(iterator) != IS_OBJECT)) {
39+
zend_type_error(
40+
"iterator() argument must be of type Traversable, %s given",
41+
zend_zval_type_name(iterator)
42+
);
3143
return NULL;
3244
}
3345

3446
ce = Z_OBJCE_P(iterator);
47+
if (UNEXPECTED(ce->get_iterator == NULL)) {
48+
zend_type_error(
49+
"iterator() argument must be of type Traversable, %s given",
50+
ZSTR_VAL(ce->name)
51+
);
52+
return NULL;
53+
}
54+
3555
it = ce->get_iterator(ce, iterator, 0);
3656
if (UNEXPECTED(!it || EG(exception))) {
3757
return NULL;
3858
}
3959

4060
if (UNEXPECTED(it->funcs->get_current_key == NULL)) {
61+
zend_iterator_dtor(it);
4162
return NULL;
4263
}
4364

4465
if (UNEXPECTED(it->funcs->rewind == NULL)) {
66+
zend_iterator_dtor(it);
4567
return NULL;
4668
}
4769

0 commit comments

Comments
 (0)