]> 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 807517093860728ccb2994b527477d70c90a29d5..b2e393327fa432af0687ee78d60dbb4dab6ebcc8 100644 (file)
@@ -825,7 +825,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