From 2729db9555d2c12b688dab5cb3eb620db7f4f904 Mon Sep 17 00:00:00 2001
From: Grant Limberg <grant.limberg@zerotier.com>
Date: Sun, 11 Nov 2018 22:55:53 -0800
Subject: [PATCH] exceptions

---
 controller/PostgreSQL.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp
index 02e2de2b8..ea04f5519 100644
--- a/controller/PostgreSQL.cpp
+++ b/controller/PostgreSQL.cpp
@@ -384,7 +384,11 @@ void PostgreSQL::initializeMembers(PGconn *conn)
 			config["nwid"] = networkId;
 			config["activeBridge"] = (strcmp(PQgetvalue(res, i, 2), "t") == 0);
 			config["authorized"] = (strcmp(PQgetvalue(res, i, 3), "t") == 0);
-			config["capabilities"] = json::parse(PQgetvalue(res, i, 4));
+			try {
+				config["capabilities"] = json::parse(PQgetvalue(res, i, 4));
+			} catch (std::exception &e) {
+				config["capabilities"] = json::array();
+			}
 			try {
 				config["creationTime"] = std::stoull(PQgetvalue(res, i, 5));
 			} catch (std::exception &e) {
@@ -410,7 +414,11 @@ void PostgreSQL::initializeMembers(PGconn *conn)
 				config["remoteTraceLevel"] = 0;
 			}
 			config["remoteTraceTarget"] = PQgetvalue(res, i, 10);
-			config["tags"] = json::parse(PQgetvalue(res, i, 11));
+			try {
+				config["tags"] = json::parse(PQgetvalue(res, i, 11));
+			} catch (std::exception &e) {
+				config["tags"] = json::array();
+			}
 			try {
 				config["vMajor"] = std::stoi(PQgetvalue(res, i, 12));
 			} catch(std::exception &e) {