From 6b1bd0d0dc9ced48785e53280256875e0f52b6d1 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Thu, 11 Jun 2009 09:49:57 +0000 Subject: [PATCH] MFH: fix bug #48518 (curl crashes when writing into invalid file handle) --- NEWS | 1 + ext/curl/interface.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 6a808f9412..58800d5d6d 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ - Updated timezone database to version 2009.9 (2009i) (Derick) - Added "ignore_errors" option to http fopen wrapper. (David Zulke, Sara) +- Fixed bug #48518 (curl crashes when writing into invalid file handle). (Tony) - Fixed bug #48469 (ldap_get_entries() leaks memory on empty search results). (Patrick) - Fixed bug #48456 (CPPFLAGS not restored properly in phpize.m4). diff --git a/ext/curl/interface.c b/ext/curl/interface.c index e04edb3936..4fcba360f6 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1437,6 +1437,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu switch (option) { case CURLOPT_FILE: if (((php_stream *) what)->mode[0] != 'r') { + zend_list_addref(Z_LVAL_PP(zvalue)); ch->handlers->write->fp = fp; ch->handlers->write->method = PHP_CURL_FILE; } else { @@ -1447,6 +1448,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu break; case CURLOPT_WRITEHEADER: if (((php_stream *) what)->mode[0] != 'r') { + zend_list_addref(Z_LVAL_PP(zvalue)); ch->handlers->write_header->fp = fp; ch->handlers->write_header->method = PHP_CURL_FILE; } else { -- 2.40.0