Skip to content

Commit 1c5d500

Browse files
committed
importer: do not iterate search path dir if error exists
If g_file_enumerate_children encounters an error for a search path it will return NULL. This can happen for directories that do not exist. It is a programmer error to pass NULL to g_file_enumerator_iterate, so break out of the directory processing loop if we do not have a directory to iterate on.
1 parent e0e48de commit 1c5d500

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

gjs/importer.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
#include <js/ComparisonOperators.h>
2525
#include <js/ErrorReport.h> // for JS_ReportOutOfMemory, JSEXN_ERR
2626
#include <js/Exception.h>
27+
#include <js/GCVector.h> // for StackGCVector
2728
#include <js/GlobalObject.h> // for CurrentGlobalOrNull
28-
#include <js/Id.h> // for PropertyKey
29-
#include <js/Object.h> // for GetClass
29+
#include <js/Id.h> // for PropertyKey
30+
#include <js/Object.h> // for GetClass
3031
#include <js/PropertyAndElement.h>
3132
#include <js/PropertyDescriptor.h>
3233
#include <js/PropertySpec.h>
@@ -671,7 +672,8 @@ static bool importer_new_enumerate(JSContext* context, JS::HandleObject object,
671672
while (true) {
672673
GFileInfo *info;
673674
GFile *file;
674-
if (!g_file_enumerator_iterate(direnum, &info, &file, NULL, NULL))
675+
if (!direnum ||
676+
!g_file_enumerator_iterate(direnum, &info, &file, NULL, NULL))
675677
break;
676678
if (info == NULL || file == NULL)
677679
break;

0 commit comments

Comments
 (0)