BUGFIX break the loop if locked_session is NULL
diff --git a/src/mod_netconf.c b/src/mod_netconf.c
index ccd62e8..af50aae 100644
--- a/src/mod_netconf.c
+++ b/src/mod_netconf.c
@@ -479,7 +479,7 @@
 	}
 	/* remove session from the active sessions list -> nobody new can now work with session */
 	for (locked_session = netconf_sessions_list;
-         strcmp(nc_session_get_id(locked_session->session), session_id);
+         locked_session && strcmp(nc_session_get_id(locked_session->session), session_id);
          locked_session = locked_session->next);
 
     if (!locked_session) {
@@ -647,7 +647,7 @@
 	}
 	/* get session where send the RPC */
 	for (locked_session = netconf_sessions_list;
-         strcmp(nc_session_get_id(locked_session->session), session_id);
+         locked_session && strcmp(nc_session_get_id(locked_session->session), session_id);
          locked_session = locked_session->next);
 	if (locked_session != NULL) {
 		session = locked_session->session;
@@ -1571,7 +1571,7 @@
 	}
 
 	for (locked_session = netconf_sessions_list;
-         strcmp(nc_session_get_id(locked_session->session), session_id);
+         locked_session && strcmp(nc_session_get_id(locked_session->session), session_id);
          locked_session = locked_session->next);
 	if ((locked_session != NULL) && (locked_session->hello_message != NULL)) {
 		DEBUG("LOCK mutex %s", __func__);
@@ -1619,7 +1619,7 @@
 	}
 
 	for (locked_session = netconf_sessions_list;
-         strcmp(nc_session_get_id(locked_session->session), session_id);
+         locked_session && strcmp(nc_session_get_id(locked_session->session), session_id);
          locked_session = locked_session->next);
 	if (locked_session != NULL) {
 		DEBUG("LOCK mutex %s", __func__);
@@ -1713,7 +1713,7 @@
 	}
 
 	for (locked_session = netconf_sessions_list;
-         strcmp(nc_session_get_id(locked_session->session), session_id);
+         locked_session && strcmp(nc_session_get_id(locked_session->session), session_id);
          locked_session = locked_session->next);
 	if (locked_session != NULL) {
 		DEBUG("LOCK mutex %s", __func__);