summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dir.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index 777fa55b63..35e9aa71d2 100644
--- a/dir.c
+++ b/dir.c
@@ -1200,7 +1200,7 @@ glob_make_pattern(const char *p, const char *e, int flags, rb_encoding *enc)
while (p < e && *p) {
tmp = GLOB_ALLOC(struct glob_pattern);
if (!tmp) goto error;
- if (p[0] == '*' && p[1] == '*' && p[2] == '/') {
+ if (p + 2 < e && p[0] == '*' && p[1] == '*' && p[2] == '/') {
/* fold continuous RECURSIVEs (needed in glob_helper) */
do { p += 3; while (*p == '/') p++; } while (p[0] == '*' && p[1] == '*' && p[2] == '/');
tmp->type = RECURSIVE;