From 40bbb48e65efc36cb2ca42b51c7e643203f16c85 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 12 Feb 2015 22:26:02 +0100 Subject: Fix errornously stored '\0' byte in config xml chunk. --- lv2/lv2.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lv2') 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); } -- cgit v1.2.3