summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-02-12 22:26:02 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2015-02-12 22:26:02 +0100
commit40bbb48e65efc36cb2ca42b51c7e643203f16c85 (patch)
treeb4b18ab687f8759f95dda0ec86e48983643b4c08
parent087087e65c0ea0b19d21c4a8b44833bf0a951e86 (diff)
Fix errornously stored '\0' byte in config xml chunk.
-rw-r--r--lv2/lv2.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/lv2/lv2.cc b/lv2/lv2.cc
index 41a5d48..d87665d 100644
--- a/lv2/lv2.cc
+++ b/lv2/lv2.cc
@@ -63,10 +63,14 @@ dg_save(LV2_Handle instance,
std::string config = dglv2->dg->configString();
+ // Backwards compatible fix for errornously stored '\0' byte in < v0.9.8.
+ // Remove when we reach v1.0
+ config += "\n";
+
store(handle,
dglv2->map->map(dglv2->map->handle, NS_DG "config"),
- config.c_str(),
- config.length() + 1, // Careful! Need space for terminator
+ config.data(),
+ config.length(),
dglv2->map->map(dglv2->map->handle, LV2_ATOM__Chunk),
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
@@ -99,7 +103,12 @@ dg_restore(LV2_Handle instance,
if(data && size) {
std::string config;
- config.append(data, size - 1);
+
+ // Fix for errornously stored '\0' byte in < v0.9.8.
+ // Remove when we reach v1.0
+ if(data[size - 1] == '\0') size--;
+
+ config.append(data, size);
dglv2->dg->setConfigString(config);
}