loader: Fix infinite loop on layer library scan if dlopen fails
diff --git a/loader/loader.c b/loader/loader.c
index 8a0b3eb..548a9aa 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -435,8 +435,10 @@
              if (!strncmp(dent->d_name, "libXGLLayer", strlen("libXGLLayer"))) {
                 void * handle;
                 snprintf(temp_str, sizeof(temp_str), "%s/%s",p,dent->d_name);
-                if ((handle = dlopen(temp_str, RTLD_LAZY)) == NULL)
+                if ((handle = dlopen(temp_str, RTLD_LAZY)) == NULL) {
+                    dent = readdir(curdir);
                     continue;
+                }
                 if (loader.scanned_layer_count == MAX_LAYER_LIBRARIES) {
                     loader_log(XGL_DBG_MSG_ERROR, 0, "%s ignored: max layer libraries exceed", temp_str);
                     break;