Skip to content

Commit cb6dea6

Browse files
committed
fix possible null pointer math
1 parent a3a0e49 commit cb6dea6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sapi/cgi/cgi_main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,13 +1661,15 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */
16611661
static void add_response_header(sapi_header_struct *h, zval *return_value TSRMLS_DC) /* {{{ */
16621662
{
16631663
char *s, *p;
1664-
int len;
1664+
int len = 0;
16651665
ALLOCA_FLAG(use_heap)
16661666

16671667
if (h->header_len > 0) {
16681668
p = strchr(h->header, ':');
1669-
len = p - h->header;
1670-
if (p && (len > 0)) {
1669+
if (NULL != p) {
1670+
len = p - h->header;
1671+
}
1672+
if (len > 0) {
16711673
while (len > 0 && (h->header[len-1] == ' ' || h->header[len-1] == '\t')) {
16721674
len--;
16731675
}

0 commit comments

Comments
 (0)