src/XMLDocumentConstructor.h
branchv_0
changeset 39 77d585a1b98c
parent 38 ba850b20fe0d
child 40 503b77beed57
--- a/src/XMLDocumentConstructor.h	Sun Jun 06 18:29:23 2021 +0200
+++ b/src/XMLDocumentConstructor.h	Mon Jun 07 18:40:45 2021 +0200
@@ -61,7 +61,7 @@
 	std::stringstream currentIndefiniteString;
 
 	uint64_t currentTag;
-	bool currentTagPresent;
+	bool currentTagPresent = false;
 
 	cbor_callbacks callbacks = cbor_empty_callbacks;
 
@@ -156,17 +156,18 @@
 	}
 
 	void flushCurrentIndefiniteString(Glib::ustring cborType) {
-		mode.pop_back();
 		appendScalarValue(currentIndefiniteString.str(), cborType);
 		currentIndefiniteString = std::stringstream();
 	}
 
 	void containerEnd() {
+		Mode m = mode.back();
+		mode.pop_back();
 		remainingItems.pop_back();
-		if (mode.back() == Mode::MAP_KEY || mode.back() == Mode::MAP_VALUE) current = parentOrSelf(current);
-		else if (mode.back() == Mode::BYTE_STRING) flushCurrentIndefiniteString("byte-string");
-		else if (mode.back() == Mode::CHAR_STRING) flushCurrentIndefiniteString("string");
-		else mode.pop_back(); // TODO: assert map/array
+		
+		if (m == Mode::MAP_KEY || m == Mode::MAP_VALUE) current = parentOrSelf(current);
+		else if (m == Mode::BYTE_STRING) flushCurrentIndefiniteString("byte-string");
+		else if (m == Mode::CHAR_STRING) flushCurrentIndefiniteString("string");
 	}
 
 public: