]> git.kaiwu.me - nginx.git/commitdiff
Fixed segfault with try_files (ticket #152).
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 19 Apr 2012 15:48:03 +0000 (15:48 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 19 Apr 2012 15:48:03 +0000 (15:48 +0000)
The problem occured if first uri in try_files was shorter than request uri,
resulting in reserve being 0 and hence allocation skipped.  The bug was
introduced in r4584 (1.1.19).

src/http/ngx_http_core_module.c

index 5b7f44aa199a025264560cc255564b5dce6109d0..42dd6644e9085cfcdf10b568693568d5dc670ece 100644 (file)
@@ -1240,7 +1240,7 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
             reserve = len > r->uri.len - alias ? len - (r->uri.len - alias) : 0;
         }
 
-        if (reserve > allocated) {
+        if (reserve > allocated || !allocated) {
 
             /* 16 bytes are preallocation */
             allocated = reserve + 16;