1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
From 0654240f24f6f619074c205462dbefe9b175c122 Mon Sep 17 00:00:00 2001
From: Derick Rethans <github@derickrethans.nl>
Date: Sat, 30 Nov 2019 17:23:53 +0000
Subject: [PATCH] Fix key generation on 32 bit platforms
---
xdebug_code_coverage.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/xdebug_code_coverage.c b/xdebug_code_coverage.c
index d7a2027fe..bd2a5f343 100644
--- a/xdebug_code_coverage.c
+++ b/xdebug_code_coverage.c
@@ -1047,18 +1047,28 @@ static int prefill_from_function_table(zend_op_array *opa)
return ZEND_HASH_APPLY_KEEP;
}
+/* Set correct int format to use */
+#if SIZEOF_ZEND_LONG == 4
+# define XDEBUG_PTR_KEY_LEN 8
+# define XDEBUG_PTR_KEY_FMT "%08X"
+#else
+# define XDEBUG_PTR_KEY_LEN 16
+# define XDEBUG_PTR_KEY_FMT "%016lX"
+#endif
+
+
static int mark_class_as_visited(zend_class_entry *ce)
{
int already_visited = 0;
void *dummy; /* we only care about key existence, not value */
- char key[17];
+ char key[XDEBUG_PTR_KEY_LEN + 1];
- snprintf(key, 17, "%016lX", (uintptr_t) ce);
+ snprintf(key, XDEBUG_PTR_KEY_LEN + 1, XDEBUG_PTR_KEY_FMT, (uintptr_t) ce);
- if (xdebug_hash_find(XG(visited_classes), key, 16, (void*) &dummy)) {
+ if (xdebug_hash_find(XG(visited_classes), key, XDEBUG_PTR_KEY_LEN, (void*) &dummy)) {
already_visited = 1;
} else {
- xdebug_hash_add(XG(visited_classes), key, 16, NULL);
+ xdebug_hash_add(XG(visited_classes), key, XDEBUG_PTR_KEY_LEN, NULL);
}
return already_visited;
|