Skip to content

Commit abefb0c

Browse files
authored
Merge branch 'php:master' into fix-ini-set-mbstring-detect-order-is-ignored
2 parents 361d654 + 9762c44 commit abefb0c

File tree

5 files changed

+36
-28
lines changed

5 files changed

+36
-28
lines changed

ext/lexbor/lexbor/url/url.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,27 +1029,34 @@ lxb_url_path_append_wo_slash(lxb_url_t *url,
10291029
static lxb_status_t
10301030
lxb_url_path_append(lxb_url_t *url, const lxb_char_t *data, size_t length)
10311031
{
1032-
size_t len;
1033-
lxb_char_t *p;
1032+
lxb_char_t *p, *begin;
10341033
lexbor_str_t *str;
10351034

10361035
str = &url->path.str;
10371036

10381037
if (str->data == NULL) {
10391038
p = lexbor_str_init(str, url->mraw, length + 1);
1040-
if (p == NULL) {
1041-
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
1042-
}
1039+
}
1040+
else {
1041+
/* + 2 == begin '/' and end '\0' */
1042+
p = lexbor_str_check_size(str, url->mraw, length + 2);
10431043
}
10441044

1045-
len = str->length;
1046-
str->length += 1;
1045+
if (p == NULL) {
1046+
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
1047+
}
10471048

1048-
p = lexbor_str_append(&url->path.str, url->mraw, data, length);
1049+
begin = &str->data[str->length];
1050+
begin[0] = '/';
10491051

1050-
str->data[len] = '/';
1052+
if (length > 0) {
1053+
memcpy(&begin[1], data, sizeof(lxb_char_t) * length);
1054+
}
10511055

1052-
return (p != NULL) ? LXB_STATUS_OK : LXB_STATUS_ERROR_MEMORY_ALLOCATION;
1056+
str->length += length + 1;
1057+
str->data[str->length] = '\0';
1058+
1059+
return LXB_STATUS_OK;
10531060
}
10541061

10551062
static lxb_status_t

ext/libxml/libxml.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,10 @@ php_libxml_output_buffer_create_filename(const char *URI,
615615
}
616616

617617
/* Allocate the Output buffer front-end. */
618-
ret = xmlAllocOutputBuffer(encoder);
619-
if (ret != NULL) {
620-
ret->context = context;
621-
ret->writecallback = php_libxml_streams_IO_write;
622-
ret->closecallback = php_libxml_streams_IO_close;
618+
ret = xmlOutputBufferCreateIO(php_libxml_streams_IO_write, php_libxml_streams_IO_close, context, encoder);
619+
if (ret == NULL) {
620+
php_libxml_streams_IO_close(context);
621+
goto err;
623622
}
624623

625624
return ret;
@@ -806,6 +805,7 @@ static xmlParserInputPtr php_libxml_external_entity_loader(const char *URL,
806805
zend_string_release(callable_name);
807806
zval_ptr_dtor(&callable);
808807
} else {
808+
#if LIBXML_VERSION < 21400
809809
/* TODO: allow storing the encoding in the stream context? */
810810
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
811811
xmlParserInputBufferPtr pib = xmlAllocParserInputBuffer(enc);
@@ -824,6 +824,12 @@ static xmlParserInputPtr php_libxml_external_entity_loader(const char *URL,
824824
xmlFreeParserInputBuffer(pib);
825825
}
826826
}
827+
#else
828+
/* make stream not being closed when the zval is freed */
829+
GC_ADDREF(stream->res);
830+
ret = xmlNewInputFromIO(NULL, php_libxml_streams_IO_read, php_libxml_streams_IO_close, stream, 0);
831+
/* Note: if ret == NULL, the close operation will be executed, so don't DELREF stream->res upon failure! */
832+
#endif
827833
}
828834
} else if (Z_TYPE(retval) != IS_NULL) {
829835
/* retval not string nor resource nor null; convert to string */

ext/soap/php_http.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,7 @@ int make_http_soap_request(
10141014
char *eqpos = strstr(cookie, "=");
10151015
char *sempos = strstr(cookie, ";");
10161016
if (eqpos != NULL && (sempos == NULL || sempos > eqpos)) {
1017-
smart_str name = {0};
1018-
int cookie_len;
1017+
size_t cookie_len;
10191018
zval zcookie;
10201019

10211020
if (sempos != NULL) {
@@ -1024,8 +1023,7 @@ int make_http_soap_request(
10241023
cookie_len = strlen(cookie)-(eqpos-cookie)-1;
10251024
}
10261025

1027-
smart_str_appendl(&name, cookie, eqpos - cookie);
1028-
smart_str_0(&name);
1026+
zend_string *name = zend_string_init(cookie, eqpos - cookie, false);
10291027

10301028
array_init(&zcookie);
10311029
add_index_stringl(&zcookie, 0, eqpos + 1, cookie_len);
@@ -1063,8 +1061,8 @@ int make_http_soap_request(
10631061
GC_ADDREF(uri->host);
10641062
}
10651063

1066-
zend_symtable_update(Z_ARRVAL_P(cookies), name.s, &zcookie);
1067-
smart_str_free(&name);
1064+
zend_symtable_update(Z_ARRVAL_P(cookies), name, &zcookie);
1065+
zend_string_release_ex(name, false);
10681066
}
10691067

10701068
cookie_itt = cookie_itt + cookie_len;

ext/xml/xml.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ void xml_startElementHandler(void *userData, const XML_Char *name, const XML_Cha
648648
val = xml_utf8_decode(attributes[1], strlen((char *)attributes[1]), parser->target_encoding);
649649

650650
ZVAL_STR(&tmp, val);
651-
zend_symtable_update(Z_ARRVAL(args[2]), att, &tmp);
651+
zend_hash_update(Z_ARRVAL(args[2]), att, &tmp);
652652

653653
attributes += 2;
654654

@@ -688,7 +688,7 @@ void xml_startElementHandler(void *userData, const XML_Char *name, const XML_Cha
688688
val = xml_utf8_decode(attributes[1], strlen((char *)attributes[1]), parser->target_encoding);
689689

690690
ZVAL_STR(&tmp, val);
691-
zend_symtable_update(Z_ARRVAL(atr), att, &tmp);
691+
zend_hash_update(Z_ARRVAL(atr), att, &tmp);
692692

693693
atcnt++;
694694
attributes += 2;

ext/zip/php_zip.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,6 @@ PHP_FUNCTION(zip_entry_read)
13031303
zend_long len = 0;
13041304
zip_read_rsrc * zr_rsrc;
13051305
zend_string *buffer;
1306-
int n = 0;
13071306

13081307
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &zip_entry, &len) == FAILURE) {
13091308
RETURN_THROWS();
@@ -1319,7 +1318,7 @@ PHP_FUNCTION(zip_entry_read)
13191318

13201319
if (zr_rsrc->zf) {
13211320
buffer = zend_string_safe_alloc(1, len, 0, false);
1322-
n = zip_fread(zr_rsrc->zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
1321+
zip_int64_t n = zip_fread(zr_rsrc->zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
13231322
if (n > 0) {
13241323
ZSTR_VAL(buffer)[n] = '\0';
13251324
ZSTR_LEN(buffer) = n;
@@ -2781,8 +2780,6 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
27812780
zend_string *filename;
27822781
zend_string *buffer;
27832782

2784-
int n = 0;
2785-
27862783
if (type == 1) {
27872784
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|ll", &filename, &len, &flags) == FAILURE) {
27882785
RETURN_THROWS();
@@ -2819,7 +2816,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
28192816
}
28202817

28212818
buffer = zend_string_safe_alloc(1, len, 0, false);
2822-
n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
2819+
zip_int64_t n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
28232820
if (n < 1) {
28242821
zend_string_efree(buffer);
28252822
RETURN_EMPTY_STRING();

0 commit comments

Comments
 (0)