]> granicus.if.org Git - php/commitdiff
fix crash on empty doc_root
authorAntony Dovgal <tony2001@php.net>
Tue, 20 Oct 2009 12:57:44 +0000 (12:57 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 20 Oct 2009 12:57:44 +0000 (12:57 +0000)
sapi/cgi/cgi_main.c

index f78cc484aaaa478d666c549a1955518c34d6ff01..449e0cf1720e63c4ff5978e97e93382ed649607d 100644 (file)
@@ -828,7 +828,7 @@ static int sapi_cgi_activate(TSRMLS_D)
                        /* DOCUMENT_ROOT should also be defined at this stage..but better check it anyway */
                        if (doc_root) {
                                doc_root_len = strlen(doc_root);
-                               if (IS_SLASH(doc_root[doc_root_len - 1])) {
+                               if (doc_root_len > 0 && IS_SLASH(doc_root[doc_root_len - 1])) {
                                        --doc_root_len;
                                }
 #ifdef PHP_WIN32