cvs: php4 /ext/curl curl.c

From: Date: Sun, 06 May 2001 22:24:27 +0000
Subject: cvs: php4 /ext/curl curl.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-5576@lists.php.net to get a copy of this message
sterling Sun May 6 15:24:27 2001 EDT Modified files: /php4/ext/curl curl.c Log: fix crash bug Index: php4/ext/curl/curl.c diff -u php4/ext/curl/curl.c:1.50 php4/ext/curl/curl.c:1.51 --- php4/ext/curl/curl.c:1.50 Thu May 3 21:20:38 2001 +++ php4/ext/curl/curl.c Sun May 6 15:24:25 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: curl.c,v 1.50 2001/05/04 04:20:38 sterling Exp $ */ +/* $Id: curl.c,v 1.51 2001/05/06 22:24:25 sterling Exp $ */ #include "php.h" @@ -483,6 +483,21 @@ } /* }}} */ +static void init_curl_handle(php_curl **ch) +{ + *ch = emalloc(sizeof(php_curl)); + (*ch)->handlers = ecalloc(1, sizeof(php_curl_handlers)); + (*ch)->handlers->write = ecalloc(1, sizeof(php_curl_write)); + (*ch)->handlers->read = ecalloc(1, sizeof(php_curl_read)); + + zend_llist_init(&(*ch)->to_free.str, sizeof(char *), + (void(*)(void *)) curl_free_string, 0); + zend_llist_init(&(*ch)->to_free.slist, sizeof(struct curl_slist), + (void(*)(void *)) curl_free_slist, 0); + zend_llist_init(&(*ch)->to_free.post, sizeof(struct HttpPost), + (void(*)(void *)) curl_free_post, 0); +} + /* {{{ proto int curl_init([string url]) Initialize a CURL session */ PHP_FUNCTION(curl_init) @@ -495,20 +510,8 @@ zend_get_parameters_ex(argc, &url) == FAILURE) { WRONG_PARAM_COUNT; } - - ch = emalloc(sizeof(php_curl)); - ch->handlers = emalloc(sizeof(php_curl_handlers)); - ch->handlers->write = emalloc(sizeof(php_curl_write)); - ch->handlers->read = emalloc(sizeof(php_curl_read)); - memset(ch->handlers->write, 0, sizeof(php_curl_write)); - memset(ch->handlers->read, 0, sizeof(php_curl_read)); - zend_llist_init(&ch->to_free.str, sizeof(char *), - (void(*)(void *)) curl_free_string, 0); - zend_llist_init(&ch->to_free.slist, sizeof(struct curl_slist), - (void(*)(void *)) curl_free_slist, 0); - zend_llist_init(&ch->to_free.post, sizeof(struct HttpPost), - (void(*)(void *)) curl_free_post, 0); + init_curl_handle(&ch); ch->cp = curl_easy_init(); if (! ch->cp) {

« previous php.cvs (#5576) next »