txlyre 2 days ago
parent
commit
24b09c4ebc
1 changed files with 8 additions and 1 deletions
  1. 8 1
      qic.c

+ 8 - 1
qic.c

@@ -5000,6 +5000,14 @@ int require_once(buffer_t *gbuf, buffer_t *buf, list_t *ctx, table_t *ltab,
         return -1;
     }
 
+    path = realpath(path, NULL);
+
+    if (is_required(path)) {
+      fclose(fd);
+
+      return 1;
+    }
+    
     buffer_t *fbuf = buffer_new();
 
     for (;;)
@@ -5013,7 +5021,6 @@ int require_once(buffer_t *gbuf, buffer_t *buf, list_t *ctx, table_t *ltab,
     }
 
     source = buffer_read(fbuf);
-    path = realpath(path, NULL);
   }
 
   list_t *pair = list_new();