← Back to team overview

zorba-coders team mailing list archive

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

 

Dennis Knochenwefel has proposed merging lp:~zorba-coders/zorba/bug-1021025 into lp:zorba.

Requested reviews:
  Till Westmann (tillw)
  Ghislain Fourny (gislenius)
Related bugs:
  Bug #1021025 in Zorba: "in json_impl.cpp data  from a zstring is read after destruction"
  https://bugs.launchpad.net/zorba/+bug/1021025

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

fix for bug #1021025
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1021025/+merge/113442
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/json/json_impl.cpp'
--- src/runtime/json/json_impl.cpp	2012-06-28 04:14:03 +0000
+++ src/runtime/json/json_impl.cpp	2012-07-04 18:06:19 +0000
@@ -25,6 +25,7 @@
 #include "system/globalenv.h"
 
 #include "util/mem_streambuf.h"
+#include "util/string_util.h"
 
 #include "jsonml_array.h"
 #include "snelson.h"
@@ -63,6 +64,7 @@
   options_type options;
   istringstream iss;
   mem_streambuf buf;
+  zstring s;
 
   PlanIteratorState *state;
   DEFAULT_STACK_INIT( PlanIteratorState, state, planState );
@@ -78,7 +80,6 @@
   if ( cur_item->isStreamable() ) {
     is = &cur_item->getStream();
   } else {
-    zstring s;
     cur_item->getStringValue2( s );
     // Doing it this way uses the string data in-place with no copy.
     buf.set( s.data(), s.size() );
@@ -104,7 +105,9 @@
   catch ( json::illegal_character const &e ) {
     throw XQUERY_EXCEPTION(
       zerr::ZJPE0001_ILLEGAL_CHARACTER,
-      ERROR_PARAMS( e.get_char() ),
+      ERROR_PARAMS(zstring("#x") + 
+      BUILD_STRING(std::uppercase << std::hex
+                   << (static_cast<unsigned int>(e.get_char()) & 0xFF)) ),
       ERROR_LOC( e.get_loc() )
     );
   }


Follow ups