← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug-1039488 into lp:zorba

 

Ghislain Fourny has proposed merging lp:~zorba-coders/zorba/bug-1039488 into lp:zorba.

Requested reviews:
  Matthias Brantner (matthias-brantner)
Related bugs:
  Bug #1039488 in Zorba: "Zorba crashes upon insert of more than one pair into an object."
  https://bugs.launchpad.net/zorba/+bug/1039488

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1039488/+merge/120548

Fixing bug 1039488.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1039488/+merge/120548
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-08-16 18:31:02 +0000
+++ src/compiler/translator/translator.cpp	2012-08-21 12:25:38 +0000
@@ -13045,8 +13045,7 @@
   RootTypeManager& rtm = GENV_TYPESYSTEM;
 
   csize numPairs = v.numPairs();
-  std::vector<expr_t> args;
-  args.reserve(1 + 2 * numPairs);
+  std::vector<expr_t> args(1 + 2 * numPairs);
 
   expr_t targetExpr = pop_nodestack();
 
@@ -13056,9 +13055,9 @@
                                   TreatIterator::JSONIQ_OBJECT_UPDATE_TARGET, // JNUP0008
                                   NULL);
 
-  args.push_back(targetExpr);
+  args[0] = targetExpr;
 
-  for (csize i = numPairs; i > 0; --i)
+  for (csize i = 0; i < numPairs; ++i)
   {
     expr_t nameExpr = pop_nodestack();
     expr_t valueExpr = pop_nodestack();
@@ -13073,8 +13072,8 @@
                                    TreatIterator::JSONIQ_OBJECT_UPDATE_VALUE, // JNUP0017
                                    NULL);
 
-    args.push_back(nameExpr);
-    args.push_back(valueExpr);
+    args[2 * (numPairs - 1 - i) + 1] = nameExpr;
+    args[2 * (numPairs - 1 - i) + 2] = valueExpr;
   }
 
   expr_t updExpr = new fo_expr(theRootSctx,

=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
--- src/runtime/json/jsoniq_functions_impl.cpp	2012-08-16 18:31:02 +0000
+++ src/runtime/json/jsoniq_functions_impl.cpp	2012-08-21 12:25:38 +0000
@@ -514,8 +514,8 @@
 
   for (csize i = 0; i < numPairs; ++i)
   {
-    consumeNext(name, theChildren[i + 1].getp(), planState);
-    consumeNext(value, theChildren[i + 2].getp(), planState);
+    consumeNext(name, theChildren[2 * i + 1].getp(), planState);
+    consumeNext(value, theChildren[2 * i + 2].getp(), planState);
 
     names[i].transfer(name);
 


Follow ups