Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions ext/lexbor/lexbor/url/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,27 +1029,34 @@ lxb_url_path_append_wo_slash(lxb_url_t *url,
static lxb_status_t
lxb_url_path_append(lxb_url_t *url, const lxb_char_t *data, size_t length)
{
size_t len;
lxb_char_t *p;
lxb_char_t *p, *begin;
lexbor_str_t *str;

str = &url->path.str;

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

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

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

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

return (p != NULL) ? LXB_STATUS_OK : LXB_STATUS_ERROR_MEMORY_ALLOCATION;
str->length += length + 1;
str->data[str->length] = '\0';

return LXB_STATUS_OK;
}

static lxb_status_t
Expand Down
16 changes: 11 additions & 5 deletions ext/libxml/libxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,10 @@ php_libxml_output_buffer_create_filename(const char *URI,
}

/* Allocate the Output buffer front-end. */
ret = xmlAllocOutputBuffer(encoder);
if (ret != NULL) {
ret->context = context;
ret->writecallback = php_libxml_streams_IO_write;
ret->closecallback = php_libxml_streams_IO_close;
ret = xmlOutputBufferCreateIO(php_libxml_streams_IO_write, php_libxml_streams_IO_close, context, encoder);
if (ret == NULL) {
php_libxml_streams_IO_close(context);
goto err;
}

return ret;
Expand Down Expand Up @@ -806,6 +805,7 @@ static xmlParserInputPtr php_libxml_external_entity_loader(const char *URL,
zend_string_release(callable_name);
zval_ptr_dtor(&callable);
} else {
#if LIBXML_VERSION < 21400
/* TODO: allow storing the encoding in the stream context? */
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
xmlParserInputBufferPtr pib = xmlAllocParserInputBuffer(enc);
Expand All @@ -824,6 +824,12 @@ static xmlParserInputPtr php_libxml_external_entity_loader(const char *URL,
xmlFreeParserInputBuffer(pib);
}
}
#else
/* make stream not being closed when the zval is freed */
GC_ADDREF(stream->res);
ret = xmlNewInputFromIO(NULL, php_libxml_streams_IO_read, php_libxml_streams_IO_close, stream, 0);
/* Note: if ret == NULL, the close operation will be executed, so don't DELREF stream->res upon failure! */
#endif
}
} else if (Z_TYPE(retval) != IS_NULL) {
/* retval not string nor resource nor null; convert to string */
Expand Down
10 changes: 4 additions & 6 deletions ext/soap/php_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,8 +1014,7 @@ int make_http_soap_request(
char *eqpos = strstr(cookie, "=");
char *sempos = strstr(cookie, ";");
if (eqpos != NULL && (sempos == NULL || sempos > eqpos)) {
smart_str name = {0};
int cookie_len;
size_t cookie_len;
zval zcookie;

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

smart_str_appendl(&name, cookie, eqpos - cookie);
smart_str_0(&name);
zend_string *name = zend_string_init(cookie, eqpos - cookie, false);

array_init(&zcookie);
add_index_stringl(&zcookie, 0, eqpos + 1, cookie_len);
Expand Down Expand Up @@ -1063,8 +1061,8 @@ int make_http_soap_request(
GC_ADDREF(uri->host);
}

zend_symtable_update(Z_ARRVAL_P(cookies), name.s, &zcookie);
smart_str_free(&name);
zend_symtable_update(Z_ARRVAL_P(cookies), name, &zcookie);
zend_string_release_ex(name, false);
}

cookie_itt = cookie_itt + cookie_len;
Expand Down
4 changes: 2 additions & 2 deletions ext/xml/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ void xml_startElementHandler(void *userData, const XML_Char *name, const XML_Cha
val = xml_utf8_decode(attributes[1], strlen((char *)attributes[1]), parser->target_encoding);

ZVAL_STR(&tmp, val);
zend_symtable_update(Z_ARRVAL(args[2]), att, &tmp);
zend_hash_update(Z_ARRVAL(args[2]), att, &tmp);

attributes += 2;

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

ZVAL_STR(&tmp, val);
zend_symtable_update(Z_ARRVAL(atr), att, &tmp);
zend_hash_update(Z_ARRVAL(atr), att, &tmp);

atcnt++;
attributes += 2;
Expand Down
7 changes: 2 additions & 5 deletions ext/zip/php_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,6 @@ PHP_FUNCTION(zip_entry_read)
zend_long len = 0;
zip_read_rsrc * zr_rsrc;
zend_string *buffer;
int n = 0;

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

if (zr_rsrc->zf) {
buffer = zend_string_safe_alloc(1, len, 0, false);
n = zip_fread(zr_rsrc->zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
zip_int64_t n = zip_fread(zr_rsrc->zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
if (n > 0) {
ZSTR_VAL(buffer)[n] = '\0';
ZSTR_LEN(buffer) = n;
Expand Down Expand Up @@ -2781,8 +2780,6 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
zend_string *filename;
zend_string *buffer;

int n = 0;

if (type == 1) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|ll", &filename, &len, &flags) == FAILURE) {
RETURN_THROWS();
Expand Down Expand Up @@ -2819,7 +2816,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
}

buffer = zend_string_safe_alloc(1, len, 0, false);
n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
zip_int64_t n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
if (n < 1) {
zend_string_efree(buffer);
RETURN_EMPTY_STRING();
Expand Down