From bc901d613d7b8f483d0c2b88a302f61270ca4944 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 4 Jun 2021 09:20:39 -0700 Subject: [PATCH] check for nulls --- controller/PostgreSQL.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index e132a7d0b..55f3c03dd 100644 --- a/controller/PostgreSQL.cpp +++ b/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 networkId = row[1].as(); @@ -625,11 +632,19 @@ void PostgreSQL::initializeMembers() } catch (std::exception &e) { config["remoteTraceLevel"] = 0; } - config["remoteTraceTarget"] = row[10].as(); - try { - config["tags"] = json::parse(row[11].as()); - } catch (std::exception &e) { + if (!config["remoteTraceTarget"].is_null()) { + config["remoteTraceTarget"] = row[10].as(); + } else { + config["remoteTraceTarget"] = ""; + } + if (config["tags"].is_null()) { config["tags"] = json::array(); + } else { + try { + config["tags"] = json::parse(row[11].as()); + } catch (std::exception &e) { + config["tags"] = json::array(); + } } try { config["vMajor"] = row[12].as();