zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #26470
[Merge] lp:~zorba-coders/zorba/fix-dbedit-parse-xml-segfault into lp:zorba
Federico Cavalieri has proposed merging lp:~zorba-coders/zorba/fix-dbedit-parse-xml-segfault into lp:zorba.
Commit message:
Fixed db:edit and fn:parse-xml segfault
Requested reviews:
Zorba Coders (zorba-coders)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix-dbedit-parse-xml-segfault/+merge/199707
Fixed db:edit and fn:parse-xml segfault
--
https://code.launchpad.net/~zorba-coders/zorba/fix-dbedit-parse-xml-segfault/+merge/199707
Your team Zorba Coders is requested to review the proposed merge of lp:~zorba-coders/zorba/fix-dbedit-parse-xml-segfault into lp:zorba.
=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp 2013-09-17 21:12:49 +0000
+++ src/store/naive/node_items.cpp 2013-12-19 19:15:18 +0000
@@ -798,35 +798,24 @@
// Before unswapping root nodes as well, their references in the type maps
// must be erased.
- store::Item_t lRootNodeType;
- store::Item_t lOtherRootNodeType;
- bool lRootHasType = getTree()->theTypesMap->get(
- getTree()->theRootNode, lRootNodeType);
- bool lOtherRootHasType = lOtherItem->getTree()->theTypesMap->get(
- lOtherItem->getTree()->theRootNode, lOtherRootNodeType);
- if(lRootHasType)
- {
- getTree()->theTypesMap->erase(getTree()->theRootNode);
- }
- if(lOtherRootHasType)
- {
- lOtherItem->getTree()->theTypesMap->erase(
- lOtherItem->getTree()->theRootNode);
- }
+ store::Item_t lRootNodeType = getTree()->getType(getTree()->theRootNode);
+ store::Item_t lOtherRootNodeType = lOtherItem->getTree()->getType(
+ lOtherItem->getTree()->theRootNode);
+
+ if (lRootNodeType != NULL)
+ getTree()->removeType(getTree()->theRootNode);
+ if (lOtherRootNodeType != NULL)
+ lOtherItem->getTree()->removeType(lOtherItem->getTree()->theRootNode);
// Now unswapping root nodes.
std::swap(getTree()->theRootNode, lOtherItem->getTree()->theRootNode);
// And putting references back into the type maps.
- if(lRootHasType)
- {
- getTree()->theTypesMap->insert(getTree()->theRootNode, lRootNodeType);
- }
- if(lOtherRootHasType)
- {
- lOtherItem->getTree()->theTypesMap->insert(
- lOtherItem->getTree()->theRootNode, lOtherRootNodeType);
- }
+ if (lRootNodeType != NULL)
+ getTree()->addType(getTree()->theRootNode, lRootNodeType);
+ if (lOtherRootNodeType != NULL)
+ lOtherItem->getTree()->addType(lOtherItem->getTree()->theRootNode,
+ lOtherRootNodeType);
// Swap flags expect hasReference.
bool lHasReference = haveReference();
=== added file 'test/rbkt/ExpQueryResults/zorba/collections/static-edit/static-edit-20.xml.res'
--- test/rbkt/ExpQueryResults/zorba/collections/static-edit/static-edit-20.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/collections/static-edit/static-edit-20.xml.res 2013-12-19 19:15:18 +0000
@@ -0,0 +1,1 @@
+<a/><d/><c/>
=== added file 'test/rbkt/Queries/zorba/collections/static-edit/static-edit-20.xq'
--- test/rbkt/Queries/zorba/collections/static-edit/static-edit-20.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/collections/static-edit/static-edit-20.xq 2013-12-19 19:15:18 +0000
@@ -0,0 +1,12 @@
+import module namespace ddl = "http://zorba.io/modules/store/static/collections/ddl";;
+import module namespace dml = "http://zorba.io/modules/store/static/collections/dml";;
+
+import module namespace ns = "http://www.example.com/example"; at "../collection_001.xqdata";
+
+ddl:create(xs:QName("ns:collection"));
+
+dml:insert(xs:QName("ns:collection"), (<a/>, <b/>, <c/>));
+
+dml:edit(dml:collection(xs:QName("ns:collection"))[2], parse-xml("<d/>")/*);
+
+dml:collection(xs:QName("ns:collection"))
Follow ups