lnc2 MAINTENANCE minor bugfixes
diff --git a/src/messages_server.c b/src/messages_server.c
index 25a6eaa..6adc987 100644
--- a/src/messages_server.c
+++ b/src/messages_server.c
@@ -846,7 +846,8 @@
             elem = elem->next;
             if (!elem) {
                 /* error */
-                break;
+                ERRARG("event");
+                return NULL;
             }
             goto next_node;
         case LYS_CONTAINER:
@@ -856,8 +857,8 @@
             break;
         default:
             /* error */
-            elem = NULL;
-            break;
+            ERRARG("event");
+            return NULL;
         }
     }
     if (!elem) {