diff --git a/mongoose.c b/mongoose.c index 538943a2..c3cb7bf1 100644 --- a/mongoose.c +++ b/mongoose.c @@ -1648,7 +1648,7 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm, path[path_size - 1] = '\0'; // Double-check remove_double_dots(path); n = strlen(path); - while (n > 0 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes + while (n > 1 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes flags = mg_vcmp(&hm->uri, "/") == 0 ? MG_FS_DIR : fs->st(path, NULL, NULL); MG_VERBOSE(("%lu %.*s -> %s %d", c->id, (int) hm->uri.len, hm->uri.ptr, path, flags)); diff --git a/src/http.c b/src/http.c index 4909f93c..559a2626 100644 --- a/src/http.c +++ b/src/http.c @@ -654,7 +654,7 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm, path[path_size - 1] = '\0'; // Double-check remove_double_dots(path); n = strlen(path); - while (n > 0 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes + while (n > 1 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes flags = mg_vcmp(&hm->uri, "/") == 0 ? MG_FS_DIR : fs->st(path, NULL, NULL); MG_VERBOSE(("%lu %.*s -> %s %d", c->id, (int) hm->uri.len, hm->uri.ptr, path, flags));