summaryrefslogtreecommitdiffstats
path: root/bug72564.patch
blob: 4d7e5c13e8baf14ac71247f18bc9827ce02ea8d4 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
From 99d6e09c3d6679bb522836c833d0cfd4f79c6014 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@php.net>
Date: Fri, 8 Jul 2016 10:46:33 +0200
Subject: [PATCH] Fixed Bug #72564 boolean always deserialized as "true"

---
 ext/wddx/wddx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index 2cc3c8b..cb0c01e 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -1013,9 +1013,9 @@ static void php_wddx_process_data(void *user_data, const XML_Char *s, int len)
 
 			case ST_BOOLEAN:
 				if (!strcmp((char *)s, "true")) {
-					Z_LVAL(ent->data) = 1;
+					ZVAL_TRUE(&ent->data);
 				} else if (!strcmp((char *)s, "false")) {
-					Z_LVAL(ent->data) = 0;
+					ZVAL_FALSE(&ent->data);
 				} else {
 					zval_ptr_dtor(&ent->data);
 					if (ent->varname) {
-- 
2.1.4

From bfc42211d3cc5aa6cd2bdb10ef5004ce22099acb Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@php.net>
Date: Fri, 8 Jul 2016 10:45:13 +0200
Subject: [PATCH] add test for bug #72564 (7.x regression)

---
 ext/wddx/tests/bug72564.phpt | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 ext/wddx/tests/bug72564.phpt

diff --git a/ext/wddx/tests/bug72564.phpt b/ext/wddx/tests/bug72564.phpt
new file mode 100644
index 0000000..4711ef8
--- /dev/null
+++ b/ext/wddx/tests/bug72564.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #72564: wddx deserialization of boolean
+--SKIPIF--
+<?php if (!extension_loaded("wddx")) print "skip"; ?>
+--FILE--
+<?php
+	foreach([true, false, NULL] as $v) {
+		$x =  wddx_serialize_value($v);
+		var_dump($x, wddx_deserialize($x));
+	}
+?>
+Done
+--EXPECT--
+string(84) "<wddxPacket version='1.0'><header/><data><boolean value='true'/></data></wddxPacket>"
+bool(true)
+string(85) "<wddxPacket version='1.0'><header/><data><boolean value='false'/></data></wddxPacket>"
+bool(false)
+string(68) "<wddxPacket version='1.0'><header/><data><null/></data></wddxPacket>"
+NULL
+Done
-- 
2.1.4