Merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 11129
Merged at revision: 11489
Proposed branch: lp:~zorba-coders/zorba/markos-scratch
Merge into: lp:zorba
Diff against target: 176 lines (+16/-29)
4 files modified
ChangeLog (+2/-0)
src/types/typeimpl.cpp (+11/-12)
src/types/typeimpl.h (+1/-1)
src/types/typeops.cpp (+2/-16)
To merge this branch: bzr merge lp:~zorba-coders/zorba/markos-scratch
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+167176@code.launchpad.net

Commit message

fixed memory error in UserDefinedXQType::isSuperTypeOf()

Description of the change

fixed memory error in UserDefinedXQType::isSuperTypeOf()

To post a comment you must log in.
Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job markos-scratch-2013-06-03T23-11-55.014Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-05-24 20:45:21 +0000
3+++ ChangeLog 2013-06-03 23:06:31 +0000
4@@ -22,6 +22,8 @@
5 * Fixed implementation of fn:deep-equal according to latest W3C spec.
6 * Must apply document ordering on the domain expression of a FOR clause, if
7 the FOR clause is followed by a sequential clause.
8+ * Fixed invalid memory access error occuring during sequence type matching
9+ for user-defined types.
10
11
12 version 2.9
13
14=== modified file 'src/types/typeimpl.cpp'
15--- src/types/typeimpl.cpp 2013-05-21 21:44:25 +0000
16+++ src/types/typeimpl.cpp 2013-06-03 23:06:31 +0000
17@@ -1500,26 +1500,26 @@
18 ********************************************************************************/
19 bool UserDefinedXQType::isSuperTypeOf(
20 const TypeManager* tm,
21- const XQType& subType,
22+ const XQType* subType,
23 const QueryLoc& loc) const
24 {
25- if (isUnion() && isGenAtomicAny() && subType.isAtomicAny())
26+ if (isUnion() && isGenAtomicAny() && subType->isAtomicAny())
27 {
28 std::vector<xqtref_t>::const_iterator ite = m_unionItemTypes.begin();
29 std::vector<xqtref_t>::const_iterator end = m_unionItemTypes.end();
30 for (; ite != end; ++ite)
31 {
32- if (TypeOps::is_subtype(tm, subType, *(*ite), loc))
33+ if (TypeOps::is_subtype(tm, *subType, *(*ite), loc))
34 return true;
35 }
36
37 return false;
38 }
39
40- if (subType.type_kind() != XQType::USER_DEFINED_KIND)
41+ if (subType->type_kind() != XQType::USER_DEFINED_KIND)
42 return false;
43
44- const UserDefinedXQType* subtype = static_cast<const UserDefinedXQType*>(&subType);
45+ const UserDefinedXQType* subtype = static_cast<const UserDefinedXQType*>(subType);
46
47 do
48 {
49@@ -1529,14 +1529,13 @@
50 return true;
51 }
52
53- if (subtype->type_kind() == XQType::USER_DEFINED_KIND)
54- {
55- subtype = static_cast<const UserDefinedXQType*>(subtype->getBaseType().getp());
56- }
57- else
58- {
59+ subType = subtype->getBaseType().getp();
60+
61+ if (subType->type_kind() != XQType::USER_DEFINED_KIND)
62 return false;
63- }
64+
65+ subtype = static_cast<const UserDefinedXQType*>(subType);
66+
67 }
68 while (subtype != NULL);
69
70
71=== modified file 'src/types/typeimpl.h'
72--- src/types/typeimpl.h 2013-05-21 21:44:25 +0000
73+++ src/types/typeimpl.h 2013-06-03 23:06:31 +0000
74@@ -802,7 +802,7 @@
75
76 bool isSuperTypeOf(
77 const TypeManager* tm,
78- const XQType& subType,
79+ const XQType* subType,
80 const QueryLoc& loc) const;
81
82 bool isSubTypeOf(const TypeManager* tm, const XQType& superType) const;
83
84=== modified file 'src/types/typeops.cpp'
85--- src/types/typeops.cpp 2013-04-23 20:38:23 +0000
86+++ src/types/typeops.cpp 2013-06-03 23:06:31 +0000
87@@ -486,9 +486,7 @@
88 case XQType::ANY_FUNCTION_TYPE_KIND:
89 case XQType::EMPTY_KIND:
90 case XQType::STRUCTURED_ITEM_KIND:
91-#ifdef ZORBA_WITH_JSON
92 case XQType::JSON_TYPE_KIND:
93-#endif
94 return true;
95
96 case XQType::USER_DEFINED_KIND:
97@@ -577,9 +575,7 @@
98 case XQType::NODE_TYPE_KIND:
99 case XQType::EMPTY_KIND:
100 case XQType::STRUCTURED_ITEM_KIND:
101-#ifdef ZORBA_WITH_JSON
102 case XQType::JSON_TYPE_KIND:
103-#endif
104 return true;
105
106 default:
107@@ -590,7 +586,6 @@
108 break;
109 }
110
111-#ifdef ZORBA_WITH_JSON
112 case XQType::JSON_TYPE_KIND:
113 {
114 if (subtype.type_kind() != XQType::JSON_TYPE_KIND)
115@@ -615,7 +610,6 @@
116 ZORBA_ASSERT(false);
117 }
118 }
119-#endif
120
121 case XQType::NODE_TYPE_KIND:
122 {
123@@ -656,9 +650,7 @@
124
125 case XQType::NODE_TYPE_KIND:
126 case XQType::ITEM_KIND:
127-#ifdef ZORBA_WITH_JSON
128 case XQType::JSON_TYPE_KIND:
129-#endif
130 case XQType::STRUCTURED_ITEM_KIND:
131 return false;
132
133@@ -710,7 +702,7 @@
134 const UserDefinedXQType& udt =
135 static_cast<const UserDefinedXQType&>(supertype);
136
137- return udt.isSuperTypeOf(tm, subtype, loc);
138+ return udt.isSuperTypeOf(tm, &subtype, loc);
139 }
140
141 default:
142@@ -822,17 +814,12 @@
143
144 case XQType::STRUCTURED_ITEM_KIND:
145 {
146-#ifdef ZORBA_WITH_JSON
147 if (subitem->isStructuredItem())
148-#else
149- if (subitem->isNode())
150-#endif
151 return true;
152
153 return false;
154 }
155
156-#ifdef ZORBA_WITH_JSON
157 case XQType::JSON_TYPE_KIND:
158 {
159 if (!subitem->isJSONItem())
160@@ -856,7 +843,6 @@
161 ZORBA_ASSERT(false);
162 }
163 }
164-#endif
165
166 case XQType::NODE_TYPE_KIND:
167 {
168@@ -904,7 +890,7 @@
169 const UserDefinedXQType& udSuperType =
170 static_cast<const UserDefinedXQType&>(supertype);
171
172- return udSuperType.isSuperTypeOf(tm, *subtype, loc);
173+ return udSuperType.isSuperTypeOf(tm, subtype.getp(), loc);
174 }
175
176 default:

Subscribers

People subscribed via source and target branches