Skip to content

Instantly share code, notes, and snippets.

View nielsdos's full-sized avatar

Niels Dossche nielsdos

  • Belgium
View GitHub Profile
#include <stdio.h>
#include <string.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
int main() {
const char *xmlContent = "<root attr=\"foo\"/>";
xmlDocPtr doc = xmlReadMemory(xmlContent, strlen(xmlContent), NULL, NULL, 0);
xmlNodePtr root = xmlDocGetRootElement(doc);
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index 125fc847036..51f2961d30c 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -2318,6 +2318,13 @@ int phar_split_fname(const char *filename, size_t filename_len, char **arch, siz
}
/* }}} */
+/* Mapping a phar should keep both the manifest and the file pointer alive. */
+static void phar_register_mapped_phar(phar_archive_data *phar)
diff --git a/Zend/Optimizer/zend_optimizer.c b/Zend/Optimizer/zend_optimizer.c
index 857968e621b..b47be052360 100644
--- a/Zend/Optimizer/zend_optimizer.c
+++ b/Zend/Optimizer/zend_optimizer.c
@@ -966,7 +966,7 @@ static void zend_optimize(zend_op_array *op_array,
}
if (ctx->debug_level & ZEND_DUMP_BEFORE_OPTIMIZER) {
- zend_dump_op_array(op_array, ZEND_DUMP_LIVE_RANGES, "before optimizer", NULL);
+ zend_dump_op_array(op_array, ZEND_DUMP_LIVE_RANGES|ZEND_DUMP_LINE_NUMBERS, "before optimizer", NULL);
@nielsdos
nielsdos / new.s
Created May 4, 2025 16:12
x86-win32
10276f90 8b 41 1c MOV EAX,dword ptr [ECX + 0x1c]
10276f93 83 ec 08 SUB ESP,0x8
10276f96 53 PUSH EBX
10276f97 56 PUSH ESI
10276f98 33 db XOR EBX,EBX
10276f9a 33 f6 XOR ESI,ESI
10276f9c 57 PUSH EDI
10276f9d 8b fa MOV EDI,EDX
10276f9f 83 c0 ff ADD EAX,-0x1
10276fa2 75 5f JNZ LAB_10277003
@nielsdos
nielsdos / new.s
Created May 4, 2025 14:53
x86-win64
180323980 48 89 5c MOV qword ptr [RSP + 0x8],RBX
24 08
180323985 48 89 74 MOV qword ptr [RSP + 0x10],RSI
24 10
18032398a 48 89 7c MOV qword ptr [RSP + 0x18],RDI
24 18
18032398f 41 56 PUSH R14
180323991 48 83 ec 40 SUB RSP,0x40
180323995 33 f6 XOR ESI,ESI
180323997 bb 01 00 MOV EBX,0x1
0x00003f60 <+0>: push %ebp
0x00003f61 <+1>: push %edi
0x00003f62 <+2>: push %esi
0x00003f63 <+3>: push %ebx
0x00003f64 <+4>: call 0x3f65 <zif_twice+5>
0x00003f69 <+9>: add $0x2,%ebx
0x00003f6f <+15>: sub $0x2c,%esp
0x00003f72 <+18>: mov %gs:0x14,%ebp
0x00003f79 <+25>: mov %ebp,0x1c(%esp)
<?php
echo 'generating tests';
for($i = 0; $i < 100000; ++$i) {
if($i % 2500 === 0) echo '.';
$test_cases[] = [
random_bytes(random_int(1, 7000)),
random_bytes(random_int(1, 3000)),
];
}
From d1a69924ee59ba5a8a9919b048182d59058e4536 Mon Sep 17 00:00:00 2001
From: nielsdos <foo@example.com>
Date: Mon, 14 Apr 2025 07:18:31 -0700
Subject: [PATCH] PoC2
---
Zend/asm/save_xmm_x86_64_ms_masm.asm | 35 +++++++++++++++++++++++++++
Zend/zend_vm_execute.h | Bin 2278108 -> 2278192 bytes
Zend/zend_vm_execute.skl | 4 +++
win32/build/config.w32 | 11 ++++++++-
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 8462492651..e4dfa407ae 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -6632,11 +6632,19 @@ static enum php_array_find_result php_array_find(const HashTable *array, zend_fc
return PHP_ARRAY_FIND_EXCEPTION;
}
- bool retval_true = zend_is_true(&retval);
- zval_ptr_dtor(&retval);
<?php
$dom = new DOMDocument;
$dom->loadXML('<root><a/><b/></root>');
foreach ($dom->documentElement->getElementsByTagName('*') as $node) {
var_dump($node);
}
$iter = $dom->documentElement->getElementsByTagName('*');