Avoid dangling pointer in curl header.str

If buf_len is zero, this would leave behind a dangling pointer
to an already released header.str. Make sure this can't happen
by always overwriting the pointer.

Closes GH-7376.
This commit is contained in:
Alexey Zamorov 2021-08-15 17:28:03 +03:00 committed by Nikita Popov
parent 30e791ed56
commit 8c292a2f9d

View File

@ -1766,9 +1766,7 @@ static int curl_debug(CURL *cp, curl_infotype type, char *buf, size_t buf_len, v
if (ch->header.str) {
zend_string_release_ex(ch->header.str, 0);
}
if (buf_len > 0) {
ch->header.str = zend_string_init(buf, buf_len, 0);
}
ch->header.str = zend_string_init(buf, buf_len, 0);
}
return 0;