summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-12-01 14:40:35 +0100
committerAnatol Belski <ab@php.net>2014-12-01 14:40:35 +0100
commitcb6dea6ea81eab46d54a0511da24fbd6eee1abe6 (patch)
treeeef2510b1ec30bdd751b6062437a388fe9bbbb77
parenta3a0e49586b2bf37b7969f6f5722d9b2aa797356 (diff)
downloadphp-git-cb6dea6ea81eab46d54a0511da24fbd6eee1abe6.tar.gz
fix possible null pointer math
-rw-r--r--sapi/cgi/cgi_main.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index b1e12f7324..41ebd494f4 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -1661,13 +1661,15 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */
static void add_response_header(sapi_header_struct *h, zval *return_value TSRMLS_DC) /* {{{ */
{
char *s, *p;
- int len;
+ int len = 0;
ALLOCA_FLAG(use_heap)
if (h->header_len > 0) {
p = strchr(h->header, ':');
- len = p - h->header;
- if (p && (len > 0)) {
+ if (NULL != p) {
+ len = p - h->header;
+ }
+ if (len > 0) {
while (len > 0 && (h->header[len-1] == ' ' || h->header[len-1] == '\t')) {
len--;
}