dinitcheck: fix nullptr deref if service can't be loaded
authorDavin McCall <davmac@davmac.org>
Mon, 30 Dec 2019 22:28:35 +0000 (08:28 +1000)
committerDavin McCall <davmac@davmac.org>
Mon, 30 Dec 2019 22:28:35 +0000 (08:28 +1000)
src/dinitcheck.cc

index c23f2649d8ef0ca54cca6f7290d13056372959a6..0f0402a6246dedadd518a66de5ce2d557685244f 100644 (file)
@@ -144,6 +144,7 @@ int main(int argc, char **argv)
 
     for (size_t i = 0; i < num_services_to_check; ++i) {
         service_record *root = service_set[services_to_check[i]];
+        if (! root) continue;
         if (root->visited) continue;
 
         // invariant: service_chain is empty
@@ -332,7 +333,7 @@ service_record *load_service(service_set_t &services, const std::string &name,
     catch (std::system_error &sys_err)
     {
         report_error(sys_err, name);
-        return nullptr;
+        throw service_description_exc(name, "Error while reading service description.");
     }
 
     if (settings.service_type != service_type_t::INTERNAL && settings.command.length() == 0) {