summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2014-03-21 16:05:04 (GMT)
committerChristian Mollekopf <chrigi_1@fastmail.fm>2014-03-21 16:05:04 (GMT)
commitcb48f40745bf4017b3a11d7a61d36cda9139c4e3 (patch)
treeb00e6699ef25d85e36cc275343e1fa1c814fa731
parent8d558ddfb088f817773d0aa214d047bbbf8fcede (diff)
downloadlibkolabxml-cb48f40745bf4017b3a11d7a61d36cda9139c4e3.tar.gz
Move xCalVersion to thread local storage.
This started to crash due to a double free while trying to add validation by parsing the serialized result again. I assume the global variable took a reference to a temporary string or alike which got then free'd again, but I'm not sure. However, this should be in thread-local storage anyways and that fixes the problem.
-rw-r--r--src/kolabformat.cpp2
-rw-r--r--src/utils.cpp11
-rw-r--r--src/utils.h6
-rw-r--r--src/xcalconversions.h4
4 files changed, 19 insertions, 4 deletions
diff --git a/src/kolabformat.cpp b/src/kolabformat.cpp
index bb0a418..10f5591 100644
--- a/src/kolabformat.cpp
+++ b/src/kolabformat.cpp
@@ -49,7 +49,7 @@ std::string productId()
std::string xCalVersion()
{
- return XCAL::global_xCalVersion;
+ return Utils::xCalVersion();
}
std::string xKolabVersion()
diff --git a/src/utils.cpp b/src/utils.cpp
index 170f6b1..5ece8cb 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -47,6 +47,7 @@ struct Global {
std::string createdUID;
std::string productId;
std::string xKolabVersion;
+ std::string xCalVersion;
ErrorSeverity errorBit;
std::string errorMessage;
@@ -80,6 +81,16 @@ std::string kolabVersion()
return ThreadLocal::inst().xKolabVersion;
}
+void setXCalVersion(const std::string &s)
+{
+ ThreadLocal::inst().xCalVersion = s;
+}
+
+std::string xCalVersion()
+{
+ return ThreadLocal::inst().xCalVersion;
+}
+
void setProductId(const std::string &s)
{
ThreadLocal::inst().productId = s;
diff --git a/src/utils.h b/src/utils.h
index 7ed26b9..2c7e579 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -72,6 +72,12 @@ void setKolabVersion(const std::string &);
std::string kolabVersion();
/**
+ * The xCal Version of the last deserialized object
+ */
+void setXCalVersion(const std::string &);
+std::string xCalVersion();
+
+/**
* A timestamp which overrides the one normally used.
*/
void setOverrideTimestamp(const cDateTime &);
diff --git a/src/xcalconversions.h b/src/xcalconversions.h
index a0489a8..9326548 100644
--- a/src/xcalconversions.h
+++ b/src/xcalconversions.h
@@ -47,8 +47,6 @@
namespace Kolab {
namespace XCAL {
-std::string global_xCalVersion;
-
const char* const XCAL_VERSION = "2.0";
const char* const XCAL_NAMESPACE = "urn:ietf:params:xml:ns:icalendar-2.0";
@@ -1948,7 +1946,7 @@ typename T::IncidencePtr deserializeIncidence(const std::string& s, bool isUrl)
}
setProductId( vcalendar.properties().prodid().text() );
- global_xCalVersion = vcalendar.properties().version().text();
+ setXCalVersion(vcalendar.properties().version().text());
setKolabVersion( vcalendar.properties().x_kolab_version().text() );
if (incidences.empty()) {