Skip to content

Fix negative SimpleXML offsets aliasing the first element - #215

Closed
iliaal wants to merge 6 commits into
PHP-8.4from
fix/sxe-negative-offset
Closed

Fix negative SimpleXML offsets aliasing the first element#215
iliaal wants to merge 6 commits into
PHP-8.4from
fix/sxe-negative-offset

Conversation

@iliaal

@iliaal iliaal commented Aug 5, 2026

Copy link
Copy Markdown
Owner

sxe_get_element_by_offset treated negative offsets as a hit on the starting node because the scan loop never runs when offset < 0. Return NULL so reads miss and writes do not mutate item[0].

shivammathur and others added 5 commits August 5, 2026 12:27
* PHP-8.2:
  Fix hMailServer URL in Windows CI (php#23055)
* PHP-8.3:
  Fix hMailServer URL in Windows CI (php#23055)
The id must be reset to NULL before calling code that can invoke
userland code, as the id remains visible after release due to a stale
pointer.

Closes phpGH-23046.
@iliaal
iliaal force-pushed the fix/sxe-negative-offset branch from 061844c to b8b2e9b Compare August 5, 2026 13:27
sxe_get_element_by_offset scanned with nodendx <= offset, so a negative
offset skipped the loop and returned the node it started from. Reads and
isset() reported the first element, and a write overwrote it. Negative
offsets now miss, and writing to one warns like an out-of-range positive
offset instead of creating a node.

Closes phpGH-23068
@iliaal
iliaal force-pushed the fix/sxe-negative-offset branch from b8b2e9b to 7bdf744 Compare August 5, 2026 13:28
@iliaal

iliaal commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream as php#23068. Extended there so a negative-offset write warns and creates nothing, instead of silently appending.

@iliaal iliaal closed this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants