Skip to content

Commit 3c2d6f7

Browse files
committed
Merge branch 'master' of https://git.php.net/repository/php-src
2 parents a96f99e + fe08b93 commit 3c2d6f7

File tree

6 files changed

+26
-15
lines changed

6 files changed

+26
-15
lines changed

ext/dom/characterdata.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ PHP_FUNCTION(dom_characterdata_substring_data)
173173

174174
length = xmlUTF8Strlen(cur);
175175

176-
if (offset < 0 || count < 0 || offset > length) {
176+
if (offset < 0 || count < 0 || ZEND_LONG_INT_OVFL(offset) || ZEND_LONG_INT_OVFL(count) || offset > length) {
177177
xmlFree(cur);
178178
php_dom_throw_error(INDEX_SIZE_ERR, dom_get_strict_error(intern->document));
179179
RETURN_FALSE;
@@ -183,7 +183,7 @@ PHP_FUNCTION(dom_characterdata_substring_data)
183183
count = length - offset;
184184
}
185185

186-
substring = xmlUTF8Strsub(cur, offset, count);
186+
substring = xmlUTF8Strsub(cur, (int)offset, (int)count);
187187
xmlFree(cur);
188188

189189
if (substring) {
@@ -257,14 +257,14 @@ PHP_FUNCTION(dom_characterdata_insert_data)
257257

258258
length = xmlUTF8Strlen(cur);
259259

260-
if (offset < 0 || offset > length) {
260+
if (offset < 0 || ZEND_LONG_INT_OVFL(offset) || offset > length) {
261261
xmlFree(cur);
262262
php_dom_throw_error(INDEX_SIZE_ERR, dom_get_strict_error(intern->document));
263263
RETURN_FALSE;
264264
}
265265

266-
first = xmlUTF8Strndup(cur, offset);
267-
second = xmlUTF8Strsub(cur, offset, length - offset);
266+
first = xmlUTF8Strndup(cur, (int)offset);
267+
second = xmlUTF8Strsub(cur, (int)offset, length - (int)offset);
268268
xmlFree(cur);
269269

270270
xmlNodeSetContent(node, first);
@@ -304,14 +304,14 @@ PHP_FUNCTION(dom_characterdata_delete_data)
304304

305305
length = xmlUTF8Strlen(cur);
306306

307-
if (offset < 0 || count < 0 || offset > length) {
307+
if (offset < 0 || count < 0 || ZEND_LONG_INT_OVFL(offset) || ZEND_LONG_INT_OVFL(count) || offset > length) {
308308
xmlFree(cur);
309309
php_dom_throw_error(INDEX_SIZE_ERR, dom_get_strict_error(intern->document));
310310
RETURN_FALSE;
311311
}
312312

313313
if (offset > 0) {
314-
substring = xmlUTF8Strsub(cur, 0, offset);
314+
substring = xmlUTF8Strsub(cur, 0, (int)offset);
315315
} else {
316316
substring = NULL;
317317
}
@@ -320,7 +320,7 @@ PHP_FUNCTION(dom_characterdata_delete_data)
320320
count = length - offset;
321321
}
322322

323-
second = xmlUTF8Strsub(cur, offset + count, length - offset);
323+
second = xmlUTF8Strsub(cur, (int)offset + (int)count, length - (int)offset);
324324
substring = xmlStrcat(substring, second);
325325

326326
xmlNodeSetContent(node, substring);
@@ -361,14 +361,14 @@ PHP_FUNCTION(dom_characterdata_replace_data)
361361

362362
length = xmlUTF8Strlen(cur);
363363

364-
if (offset < 0 || count < 0 || offset > length) {
364+
if (offset < 0 || count < 0 || ZEND_LONG_INT_OVFL(offset) || ZEND_LONG_INT_OVFL(count) || offset > length) {
365365
xmlFree(cur);
366366
php_dom_throw_error(INDEX_SIZE_ERR, dom_get_strict_error(intern->document));
367367
RETURN_FALSE;
368368
}
369369

370370
if (offset > 0) {
371-
substring = xmlUTF8Strsub(cur, 0, offset);
371+
substring = xmlUTF8Strsub(cur, 0, (int)offset);
372372
} else {
373373
substring = NULL;
374374
}
@@ -378,7 +378,7 @@ PHP_FUNCTION(dom_characterdata_replace_data)
378378
}
379379

380380
if (offset < length) {
381-
second = xmlUTF8Strsub(cur, offset + count, length - offset);
381+
second = xmlUTF8Strsub(cur, (int)offset + count, length - (int)offset);
382382
}
383383

384384
substring = xmlStrcat(substring, (xmlChar *) arg);

ext/dom/document.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ int dom_document_standalone_read(dom_object *obj, zval *retval)
382382
int dom_document_standalone_write(dom_object *obj, zval *newval)
383383
{
384384
xmlDoc *docp = (xmlDocPtr) dom_object_get_node(obj);
385-
int standalone;
385+
zend_long standalone;
386386

387387
if (docp == NULL) {
388388
php_dom_throw_error(INVALID_STATE_ERR, 0);
@@ -978,9 +978,9 @@ PHP_FUNCTION(dom_document_import_node)
978978
xmlNodePtr nodep, retnodep;
979979
dom_object *intern, *nodeobj;
980980
int ret;
981-
zend_long recursive = 0;
981+
zend_bool recursive = 0;
982982

983-
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &id, dom_document_class_entry, &node, dom_node_class_entry, &recursive) == FAILURE) {
983+
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|b", &id, dom_document_class_entry, &node, dom_node_class_entry, &recursive) == FAILURE) {
984984
return;
985985
}
986986

@@ -1728,9 +1728,14 @@ PHP_FUNCTION(dom_document_xinclude)
17281728
return;
17291729
}
17301730

1731+
if (ZEND_LONG_EXCEEDS_INT(flags)) {
1732+
php_error_docref(NULL, E_WARNING, "Invalid flags");
1733+
RETURN_FALSE;
1734+
}
1735+
17311736
DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
17321737

1733-
err = xmlXIncludeProcessFlags(docp, flags);
1738+
err = xmlXIncludeProcessFlags(docp, (int)flags);
17341739

17351740
/* XML_XINCLUDE_START and XML_XINCLUDE_END nodes need to be removed as these
17361741
are added via xmlXIncludeProcess to mark beginning and ending of xincluded document

ext/opcache/Optimizer/block_pass.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,7 @@ static void zend_t_usage(zend_code_block *block, zend_op_array *op_array, zend_b
18661866
case ZEND_ASSIGN_SUB:
18671867
case ZEND_ASSIGN_MUL:
18681868
case ZEND_ASSIGN_DIV:
1869+
case ZEND_ASSIGN_POW:
18691870
case ZEND_ASSIGN_MOD:
18701871
case ZEND_ASSIGN_SL:
18711872
case ZEND_ASSIGN_SR:

ext/opcache/Optimizer/compact_literals.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
263263
case ZEND_ASSIGN_SUB:
264264
case ZEND_ASSIGN_MUL:
265265
case ZEND_ASSIGN_DIV:
266+
case ZEND_ASSIGN_POW:
266267
case ZEND_ASSIGN_MOD:
267268
case ZEND_ASSIGN_SL:
268269
case ZEND_ASSIGN_SR:

ext/opcache/Optimizer/pass2.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ void zend_optimizer_pass2(zend_op_array *op_array)
4545
case ZEND_SUB:
4646
case ZEND_MUL:
4747
case ZEND_DIV:
48+
case ZEND_POW:
4849
if (ZEND_OP1_TYPE(opline) == IS_CONST) {
4950
if (Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_STRING) {
5051
convert_scalar_to_number(&ZEND_OP1_LITERAL(opline));
@@ -55,6 +56,7 @@ void zend_optimizer_pass2(zend_op_array *op_array)
5556
case ZEND_ASSIGN_SUB:
5657
case ZEND_ASSIGN_MUL:
5758
case ZEND_ASSIGN_DIV:
59+
case ZEND_ASSIGN_POW:
5860
if (opline->extended_value != 0) {
5961
/* object tristate op - don't attempt to optimize it! */
6062
break;

ext/opcache/Optimizer/zend_optimizer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ void zend_optimizer_update_op2_const(zend_op_array *op_array,
234234
case ZEND_ASSIGN_SUB:
235235
case ZEND_ASSIGN_MUL:
236236
case ZEND_ASSIGN_DIV:
237+
case ZEND_ASSIGN_POW:
237238
case ZEND_ASSIGN_MOD:
238239
case ZEND_ASSIGN_SL:
239240
case ZEND_ASSIGN_SR:
@@ -253,6 +254,7 @@ void zend_optimizer_update_op2_const(zend_op_array *op_array,
253254
(opline-1)->opcode == ZEND_ASSIGN_SUB ||
254255
(opline-1)->opcode == ZEND_ASSIGN_MUL ||
255256
(opline-1)->opcode == ZEND_ASSIGN_DIV ||
257+
(opline-1)->opcode == ZEND_ASSIGN_POW ||
256258
(opline-1)->opcode == ZEND_ASSIGN_MOD ||
257259
(opline-1)->opcode == ZEND_ASSIGN_SL ||
258260
(opline-1)->opcode == ZEND_ASSIGN_SR ||

0 commit comments

Comments
 (0)