Index: cpp/frams/util/extvalue.cpp
===================================================================
--- cpp/frams/util/extvalue.cpp	(revision 733)
+++ cpp/frams/util/extvalue.cpp	(revision 753)
@@ -1,4 +1,4 @@
 // This file is a part of Framsticks SDK.  http://www.framsticks.com/
-// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
+// Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
 // See LICENSE.txt for details.
 
@@ -748,27 +748,27 @@
 SString ExtValue::formatTime(char fmt, double value)
 {
-if (fmt=='i')
+	if (fmt == 'i')
 	{ //could be Convert::ctime()
-	int d,h,m,ti=value;
-	int ms=1000*(value-ti);
-	d=ti/86400; ti-=d*86400;
-	h=ti/3600; ti-=h*3600;
-	m=ti/60; ti-=m*60;
-	SString ret;
-	if (d>0) ret+=SString::sprintf("%dd ",d);
-	if (h>0) ret+=SString::sprintf("%d:",h);
-	ret+=SString::sprintf("%02d:%02d.%03d", m,ti,ms);
-	return ret;
-	}
-time_t ti = value;
-struct tm tm = Convert::localtime(ti);
-switch(fmt)
+		int d, h, m, ti = value;
+		int ms = 1000 * (value - ti);
+		d = ti / 86400; ti -= d * 86400;
+		h = ti / 3600; ti -= h * 3600;
+		m = ti / 60; ti -= m * 60;
+		SString ret;
+		if (d > 0) ret += SString::sprintf("%dd ", d);
+		if (h > 0) ret += SString::sprintf("%d:", h);
+		ret += SString::sprintf("%02d:%02d.%03d", m, ti, ms);
+		return ret;
+	}
+	time_t ti = value;
+	struct tm tm = Convert::localtime(ti);
+	switch (fmt)
 	{
 	case 'T': return SString::sprintf("%04d-%02d-%02d %02d:%02d:%02d", 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
 	case 't': return SString(Convert::asctime(tm).c_str());
 	case 'y': return SString::sprintf("%04d-%02d-%02d", 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday);
-	case 'm': return SString::sprintf("%04d-%02d-%02d %02d:%02d:%02d.%03d", 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, int(1000*(value-(double)ti)));
-	}
-return SString();
+	case 'm': return SString::sprintf("%04d-%02d-%02d %02d:%02d:%02d.%03d", 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, int(1000 * (value - (double)ti)));
+	}
+	return SString();
 }
 
@@ -834,5 +834,5 @@
 		case 't': case 'T': case 'i': case 'y': case 'm':
 			a = args.getNext();
-			ret += formatTime(type,a ? a->getDouble() : 0);
+			ret += formatTime(type, a ? a->getDouble() : 0);
 			ret += sub.substr(2);
 			break;
@@ -865,5 +865,5 @@
 	}
 	else
-		setDouble(fmod(ddata(),a));
+		setDouble(fmod(ddata(), a));
 }
 
@@ -1112,20 +1112,36 @@
 		tlsGetRef(ExtObject_serialization).add(o);
 		const char* p = in + 1;
-		ExtValue tmp;
-		while (*p)
-		{
-			if (isspace(*p)) p++;
-			if (*p == ']') { p++; break; }
+		ExtValue tmp; bool first = true, comma = false;
+		const char* prev_element = p;
+		while (true)
+		{
+			while (isspace(*p)) p++;
+			if (*p == 0)
+			{
+				logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing ']' in Vector");
+				return NULL;
+			}
+			if (*p == ']')
+			{
+				if (comma)
+				{
+					logPrintf("ExtValue", "deserialize", LOG_ERROR, "No element after ',' in Vector");
+					return NULL;
+				}
+				p++;
+				break;
+			}
+			if (!first && !comma)
+			{
+				logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing ',' in Vector: '%s'", prev_element);
+				return NULL;
+			}
 			ret = tmp.deserialize(p);
+			prev_element = p; first = false; comma = false;
 			if (ret)
 			{
 				vec->data += new ExtValue(tmp);
 				p = ret;
-				if (*p == ',') p++;
-				else if (*p != ']')
-				{
-					logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing ',' in Vector: '%s'", p);
-					return NULL;
-				}
+				if (*p == ',') { p++; comma = true; }
 			}
 			else
@@ -1145,9 +1161,31 @@
 		const char* p = in + 1;
 		ExtValue args[2]/*={value,key}*/, dummy_ret;
-		while (*p)
-		{
-			if (isspace(*p)) p++;
-			if (*p == '}') { p++; break; }
+		bool first = true, comma = false;
+		const char* prev_element = p;
+		while (true)
+		{
+			while (isspace(*p)) p++;
+			if (*p == 0)
+			{
+				logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing '}' in Dictionary");
+				return NULL;
+			}
+			if (*p == '}')
+			{
+				if (comma)
+				{
+					logPrintf("ExtValue", "deserialize", LOG_ERROR, "No element after ',' in Dictionary");
+					return NULL;
+				}
+				p++;
+				break;
+			}
+			if (!first && !comma)
+			{
+				logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing ',' in Dictionary: '%s'", prev_element);
+				return NULL;
+			}
 			ret = args[1].deserialize(p);
+			prev_element = p; first = false; comma = false;
 			if ((!ret) || (args[1].getType() != TString)) { p = NULL; break; }
 			p = ret;
@@ -1158,10 +1196,5 @@
 			p = ret;
 			dic->p_set(args, &dummy_ret);
-			if (*p == ',') p++;
-			else if (*p != '}')
-			{
-				logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing ',' in Dictionary: '%s'", p);
-				return NULL;
-			}
+			if (*p == ',') { p++; comma = true; }
 		}
 		setObject(o);
