浏览代码

check for nulls

Grant Limberg 4 年之前
父节点
当前提交
bc901d613d
共有 1 个文件被更改,包括 19 次插入4 次删除
  1. 19 4
      controller/PostgreSQL.cpp

+ 19 - 4
controller/PostgreSQL.cpp

@@ -590,6 +590,13 @@ void PostgreSQL::initializeMembers()
 
 			initMember(config);
 
+			if (row[0].is_null()) {
+				fprintf(stderr, "Null memberID?!?\n");
+				continue;
+			}			
+			if (row[1].is_null()) {
+				fprintf(stderr, "Null NetworkID?!?\n");
+			}
 			std::string memberId = row[0].as<std::string>();
 			std::string networkId = row[1].as<std::string>();
 
@@ -625,11 +632,19 @@ void PostgreSQL::initializeMembers()
 			} catch (std::exception &e) {
 				config["remoteTraceLevel"] = 0;
 			}
-			config["remoteTraceTarget"] = row[10].as<std::string>();
-			try {
-				config["tags"] = json::parse(row[11].as<std::string>());
-			} catch (std::exception &e) {
+			if (!config["remoteTraceTarget"].is_null()) {
+				config["remoteTraceTarget"] = row[10].as<std::string>();
+			} else {
+				config["remoteTraceTarget"] = "";
+			}
+			if (config["tags"].is_null()) {
 				config["tags"] = json::array();
+			} else {
+				try {
+					config["tags"] = json::parse(row[11].as<std::string>());
+				} catch (std::exception &e) {
+					config["tags"] = json::array();
+				}
 			}
 			try {
 				config["vMajor"] = row[12].as<int>();