Skip to content

Commit

Permalink
Make specifying recursion limit more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
konsolebox committed Aug 5, 2016
1 parent 55caa0a commit 5046fc2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/document.c
Original file line number Diff line number Diff line change
Expand Up @@ -1572,8 +1572,9 @@ void document_open_files_recursively(const GSList *filenames, gboolean readonly,
GFileType file_type;
GError *my_error = NULL;

enum { ENUM_STACK_LIMIT = 100 };
GFileEnumerator *enum_stack[ENUM_STACK_LIMIT];
const guint RECURSION_LIMIT = 100;
const guint ENUM_STACK_SIZE = RECURSION_LIMIT - 1;
GFileEnumerator *enum_stack[ENUM_STACK_SIZE];
guint enum_stack_index = 0;

const gchar* attributes = G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_NAME ","
Expand Down Expand Up @@ -1611,7 +1612,7 @@ void document_open_files_recursively(const GSList *filenames, gboolean readonly,

if (file_type == G_FILE_TYPE_DIRECTORY)
{
if (enum_stack_index == ENUM_STACK_LIMIT)
if (enum_stack_index == ENUM_STACK_SIZE)
{
my_error = g_error_new(0, 0, "Recursion depth limit reached");
break;
Expand Down

0 comments on commit 5046fc2

Please sign in to comment.