From 86cebd4ccae1d0c5702ad75f1b0fb0d634bb8680 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Tue, 12 Jul 2016 15:44:36 +0300 Subject: [core] Report conversion errors using std::string char* increases the risk of pointing to a invalid reference. Qt had to use a static variable as retainer to workaround. --- platform/qt/src/qt_geojson.hpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'platform/qt/src/qt_geojson.hpp') diff --git a/platform/qt/src/qt_geojson.hpp b/platform/qt/src/qt_geojson.hpp index ff7ee2eada..fd2b689fed 100644 --- a/platform/qt/src/qt_geojson.hpp +++ b/platform/qt/src/qt_geojson.hpp @@ -29,22 +29,16 @@ Result convertGeoJSON(const QVariant& value) { d.Parse<0>(value.toByteArray().constData()); } - // Needed to keep the error message alive - // when we go out of this scope. - static std::string error; - if (d.HasParseError()) { std::stringstream message; message << d.GetErrorOffset() << " - " << rapidjson::GetParseError_En(d.GetParseError()); - error = message.str(); - return Error { error.c_str() }; + return Error { message.str() }; } conversion::Result geoJSON = conversion::convertGeoJSON(d); if (!geoJSON) { - error = geoJSON.error().message; - return Error { error.c_str() }; + return Error { geoJSON.error().message }; } return geoJSON; -- cgit v1.2.1