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
9 changes: 1 addition & 8 deletions ext/dom/element.c
Original file line number Diff line number Diff line change
Expand Up @@ -1210,19 +1210,17 @@ Since: DOM Level 2
*/
PHP_METHOD(DOMElement, getAttributeNodeNS)
{
zval *id;
xmlNodePtr elemp;
xmlAttrPtr attrp;
dom_object *intern;
size_t uri_len, name_len;
char *uri, *name;

id = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!s", &uri, &uri_len, &name, &name_len) == FAILURE) {
RETURN_THROWS();
}

DOM_GET_OBJ(elemp, id, xmlNodePtr, intern);
DOM_GET_OBJ(elemp, ZEND_THIS, xmlNodePtr, intern);

bool follow_spec = php_dom_follow_spec_intern(intern);
if (follow_spec && uri_len == 0) {
Expand All @@ -1239,16 +1237,11 @@ PHP_METHOD(DOMElement, getAttributeNodeNS)
/* Keep parent alive, because we're a fake child. */
GC_ADDREF(&intern->std);
(void) php_dom_create_fake_namespace_decl(elemp, nsptr, return_value, intern);
} else {
RETURN_NULL();
}
} else {
RETURN_NULL();
}
} else {
DOM_RET_OBJ((xmlNodePtr) attrp, intern);
}

}
/* }}} end dom_element_get_attribute_node_ns */

Expand Down
17 changes: 4 additions & 13 deletions ext/dom/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -1878,8 +1878,7 @@ static void dom_node_lookup_prefix(INTERNAL_FUNCTION_PARAMETERS, bool modern)
case XML_DOCUMENT_FRAG_NODE:
case XML_DOCUMENT_TYPE_NODE:
case XML_DTD_NODE:
RETURN_NULL();
break;
return;
default:
lookupp = nodep->parent;
}
Expand All @@ -1898,8 +1897,6 @@ static void dom_node_lookup_prefix(INTERNAL_FUNCTION_PARAMETERS, bool modern)
}
}
}

RETURN_NULL();
}

PHP_METHOD(DOMNode, lookupPrefix)
Expand Down Expand Up @@ -2065,16 +2062,14 @@ PHP_METHOD(DOMNode, lookupNamespaceURI)
prefix = NULL;
}
const char *ns_uri = dom_locate_a_namespace(nodep, prefix);
if (ns_uri == NULL) {
RETURN_NULL();
} else {
if (ns_uri != NULL) {
RETURN_STRING(ns_uri);
}
} else {
if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) {
nodep = xmlDocGetRootElement((xmlDocPtr) nodep);
if (nodep == NULL) {
RETURN_NULL();
return;
}
}

Expand All @@ -2083,8 +2078,6 @@ PHP_METHOD(DOMNode, lookupNamespaceURI)
RETURN_STRING((char *) nsptr->href);
}
}

RETURN_NULL();
}
/* }}} end dom_node_lookup_namespace_uri */

Expand Down Expand Up @@ -2294,21 +2287,19 @@ static void dom_node_get_node_path(INTERNAL_FUNCTION_PARAMETERS, bool throw)
zval *id;
xmlNode *nodep;
dom_object *intern;
char *value;

ZEND_PARSE_PARAMETERS_NONE();

DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern);

value = (char *) xmlGetNodePath(nodep);
char *value = (char *) xmlGetNodePath(nodep);
if (value == NULL) {
/* This is only possible when an invalid argument is passed (e.g. namespace declaration, but that's not the case for this call site),
* or on allocation failure. So in other words, this only happens on allocation failure. */
if (throw) {
php_dom_throw_error(INVALID_STATE_ERR, /* strict */ true);
RETURN_THROWS();
}
RETURN_NULL();
} else {
RETVAL_STRING(value);
xmlFree(value);
Expand Down
2 changes: 1 addition & 1 deletion ext/phar/phar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ static zend_result phar_open_from_fp(php_stream* fp, char *fname, size_t fname_l
}

if (got >= 512) {
if (phar_is_tar((char *) pos, fname)) { /* TODO: fix const correctness */
if (phar_is_tar(pos, fname)) {
php_stream_rewind(fp);
return phar_parse_tarfile(fp, fname, fname_len, alias, alias_len, pphar, compression, error);
}
Expand Down
2 changes: 1 addition & 1 deletion ext/phar/phar_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ zend_result phar_open_archive_fp(phar_archive_data *phar);
zend_result phar_copy_on_write(phar_archive_data **pphar);

/* tar functions in tar.c */
bool phar_is_tar(char *buf, char *fname);
bool phar_is_tar(const char *buf, const char *fname);
zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data** pphar, uint32_t compression, char **error);
ZEND_ATTRIBUTE_NONNULL_ARGS(1, 7, 8) zend_result phar_open_or_create_tar(char *fname, size_t fname_len, char *alias, size_t alias_len, bool is_data, uint32_t options, phar_archive_data** pphar, char **error);
ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) void phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error);
Expand Down
6 changes: 3 additions & 3 deletions ext/phar/tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ static zend_result phar_tar_octal(char *buf, uint32_t val, size_t len) /* {{{ */
}
/* }}} */

static uint32_t phar_tar_checksum(char *buf, size_t len) /* {{{ */
static uint32_t phar_tar_checksum(const char *buf, size_t len) /* {{{ */
{
uint32_t sum = 0;
char *end = buf + len;
const char *end = buf + len;

while (buf != end) {
sum += (unsigned char)*buf;
Expand All @@ -100,7 +100,7 @@ static uint32_t phar_tar_checksum(char *buf, size_t len) /* {{{ */
}
/* }}} */

bool phar_is_tar(char *buf, char *fname) /* {{{ */
bool phar_is_tar(const char *buf, const char *fname) /* {{{ */
{
tar_header *header = (tar_header *) buf;
uint32_t checksum = phar_tar_number(header->checksum, sizeof(header->checksum));
Expand Down
10 changes: 3 additions & 7 deletions ext/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1413,14 +1413,10 @@ PHP_METHOD(SimpleXMLElement, asXML)

static inline void sxe_add_namespace_name_raw(zval *return_value, const char *prefix, const char *href)
{
zend_string *key = zend_string_init(prefix, strlen(prefix), 0);
zval zv;

if (!zend_hash_exists(Z_ARRVAL_P(return_value), key)) {
ZVAL_STRING(&zv, href);
zend_hash_add_new(Z_ARRVAL_P(return_value), key, &zv);
zval *zv = zend_hash_str_lookup(Z_ARRVAL_P(return_value), prefix, strlen(prefix));
if (Z_ISNULL_P(zv)) {
ZVAL_STRING(zv, href);
}
zend_string_release_ex(key, 0);
}

static inline void sxe_add_namespace_name(zval *return_value, xmlNsPtr ns) /* {{{ */
Expand Down
1 change: 1 addition & 0 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ static PHP_INI_MH(OnChangeMemoryLimit)

zend_ini_entry *max_mem_limit_ini = zend_hash_str_find_ptr(EG(ini_directives), ZEND_STRL("max_memory_limit"));
entry->value = zend_string_init(ZSTR_VAL(max_mem_limit_ini->value), ZSTR_LEN(max_mem_limit_ini->value), true);
GC_MAKE_PERSISTENT_LOCAL(entry->value);
PG(memory_limit) = PG(max_memory_limit);

return SUCCESS;
Expand Down