diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c index 450a48e50..fb46d65d1 100644 --- a/src/http/modules/ngx_http_autoindex_module.c +++ b/src/http/modules/ngx_http_autoindex_module.c @@ -489,8 +489,11 @@ ngx_http_autoindex_handler(ngx_http_request_t *r) } b->last = ngx_cpymem(b->last, "", sizeof("") - 1); - ngx_memset(b->last, ' ', NGX_HTTP_AUTOINDEX_NAME_LEN - len); - b->last += NGX_HTTP_AUTOINDEX_NAME_LEN - len; + + if (NGX_HTTP_AUTOINDEX_NAME_LEN - len > 0) { + ngx_memset(b->last, ' ', NGX_HTTP_AUTOINDEX_NAME_LEN - len); + b->last += NGX_HTTP_AUTOINDEX_NAME_LEN - len; + } } *b->last++ = ' ';