Fix NetconfAccess::listInstances segfault

The segfault happened when no instances were returned by getConfig.

Change-Id: Ia3765cf04e635d58d665120a3a77d81446901108
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index 4cffb52..cdd9849 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -195,6 +195,9 @@
 
     auto instances = m_session->getConfig(NC_DATASTORE_RUNNING, list->print_mem(LYD_XML, 0));
 
+    if (!instances) {
+        return res;
+    }
 
     for (const auto& instance : instances->find_path(path.c_str())->data()) {
         ListInstance instanceRes;
diff --git a/tests/data_query.cpp b/tests/data_query.cpp
index 1fd461c..e0e2875 100644
--- a/tests/data_query.cpp
+++ b/tests/data_query.cpp
@@ -75,6 +75,14 @@
             };
         }
 
+        SECTION("example-schema:person - no instances")
+        {
+            node.first = "example-schema";
+            node.second = "person";
+            expected = {
+            };
+        }
+
         SECTION("example-schema:selectedNumbers")
         {
             datastore.createListInstance("/example-schema:selectedNumbers[value='45']");