From 00cc26fde62572b0bca0cc19cf2c7a40efa12168 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Wed, 3 Dec 2014 11:52:53 -0800 Subject: [PATCH] Fixed OCSerialization NVP Header Reset OCSerialization was not resetting the name-value pair header on error, so this fixes that issue. When searching for a NVP that doesn't exist, cereal/RapidJSON will leave the iterator in a 'bad' place that can result in not being able to find what we're looking for. Change-Id: I40c1ee5397ebf2e0eb771ed8a209ea9e75757a33 Signed-off-by: Erich Keane --- resource/include/OCSerialization.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/resource/include/OCSerialization.h b/resource/include/OCSerialization.h index bbdd200..65b539a 100644 --- a/resource/include/OCSerialization.h +++ b/resource/include/OCSerialization.h @@ -57,6 +57,7 @@ namespace OC { // we swallow this exception, since it means the key // doesn't exist, allowing these to be optional + ar.setNextName(nullptr); } try @@ -70,20 +71,26 @@ namespace OC ar(cereal::make_nvp(OC::Key::PORTKEY, m_port)); } catch(cereal::Exception&) - {} + { + ar.setNextName(nullptr); + } try { ar(cereal::make_nvp(OC::Key::RESOURCETYPESKEY,m_resourceTypes)); } catch(cereal::Exception&) - {} + { + ar.setNextName(nullptr); + } try { ar(cereal::make_nvp(OC::Key::INTERFACESKEY, m_interfaces)); } catch(cereal::Exception&) - {} + { + ar.setNextName(nullptr); + } } bool m_observable; @@ -110,14 +117,18 @@ namespace OC m_loaded=true; } catch(cereal::Exception&) - {} + { + ar.setNextName(nullptr); + } try { ar(cereal::make_nvp(OC::Key::PROPERTYKEY, m_props)); m_loaded=true; } catch(cereal::Exception&) - {} + { + ar.setNextName(nullptr); + } } -- 2.7.4