svn: /pecl/amqp/trunk/ amqp_channel.c amqp_connection.c amqp_envelope.c amqp_exchange.c amqp_queue.c

From: Date: Fri, 13 Jan 2012 01:48:30 +0000
Subject: svn: /pecl/amqp/trunk/ amqp_channel.c amqp_connection.c amqp_envelope.c amqp_exchange.c amqp_queue.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-17452@lists.php.net to get a copy of this message
pdezwart Fri, 13 Jan 2012 01:48:30 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=322159 Log: * FINALLY fixing stupid print_r/var_dump segfault/memory leak Changed paths: U pecl/amqp/trunk/amqp_channel.c U pecl/amqp/trunk/amqp_connection.c U pecl/amqp/trunk/amqp_envelope.c U pecl/amqp/trunk/amqp_exchange.c U pecl/amqp/trunk/amqp_queue.c Modified: pecl/amqp/trunk/amqp_channel.c =================================================================== --- pecl/amqp/trunk/amqp_channel.c 2012-01-13 01:20:51 UTC (rev 322158) +++ pecl/amqp/trunk/amqp_channel.c 2012-01-13 01:48:30 UTC (rev 322159) @@ -49,10 +49,8 @@ /* Get the envelope object from which to read */ amqp_channel_object *channel = (amqp_channel_object *)zend_object_store_get_object(object TSRMLS_CC); - if (channel->debug_info) { - zend_hash_destroy(channel->debug_info); - efree(channel->debug_info); - } + /* Super magic make shit work variable. Seriously though, without this using print_r and/or var_dump will either cause memory leak or crash. */ + *is_temp = 1; /* Keep the first number matching the number of entries in this table*/ ALLOC_HASHTABLE(channel->debug_info); @@ -90,11 +88,6 @@ zval_ptr_dtor(&channel->connection); } - if (channel->debug_info) { - zend_hash_destroy(channel->debug_info); - efree(channel->debug_info); - } - zend_object_std_dtor(&channel->zo TSRMLS_CC); efree(object); Modified: pecl/amqp/trunk/amqp_connection.c =================================================================== --- pecl/amqp/trunk/amqp_connection.c 2012-01-13 01:20:51 UTC (rev 322158) +++ pecl/amqp/trunk/amqp_connection.c 2012-01-13 01:48:30 UTC (rev 322159) @@ -45,14 +45,12 @@ HashTable *amqp_connection_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC) { zval *value; + /* Super magic make shit work variable. Seriously though, without this using print_r and/or var_dump will either cause memory leak or crash. */ + *is_temp = 1; + /* Get the envelope object from which to read */ amqp_connection_object *connection = (amqp_connection_object *)zend_object_store_get_object(object TSRMLS_CC); - - if (connection->debug_info) { - zend_hash_destroy(connection->debug_info); - efree(connection->debug_info); - } - + /* Keep the first number matching the number of entries in this table*/ ALLOC_HASHTABLE(connection->debug_info); ZEND_INIT_SYMTABLE_EX(connection->debug_info, 5 + 1, 0); @@ -319,11 +317,6 @@ efree(connection->connection_resource); } - if (connection->debug_info) { - zend_hash_destroy(connection->debug_info); - efree(connection->debug_info); - } - zend_object_std_dtor(&connection->zo TSRMLS_CC); efree(object); Modified: pecl/amqp/trunk/amqp_envelope.c =================================================================== --- pecl/amqp/trunk/amqp_envelope.c 2012-01-13 01:20:51 UTC (rev 322158) +++ pecl/amqp/trunk/amqp_envelope.c 2012-01-13 01:48:30 UTC (rev 322159) @@ -48,10 +48,8 @@ /* Get the envelope object from which to read */ amqp_envelope_object *envelope = (amqp_envelope_object *)zend_object_store_get_object(object TSRMLS_CC); - if (envelope->debug_info) { - zend_hash_destroy(envelope->debug_info); - efree(envelope->debug_info); - } + /* Super magic make shit work variable. Seriously though, without this using print_r and/or var_dump will either cause memory leak or crash. */ + *is_temp = 1; /* Keep the # 18 matching the number of entries in this table*/ ALLOC_HASHTABLE(envelope->debug_info); @@ -145,11 +143,6 @@ efree(envelope->body); } - if (envelope->debug_info) { - zend_hash_destroy(envelope->debug_info); - efree(envelope->debug_info); - } - zend_object_std_dtor(&envelope->zo TSRMLS_CC); efree(object); Modified: pecl/amqp/trunk/amqp_exchange.c =================================================================== --- pecl/amqp/trunk/amqp_exchange.c 2012-01-13 01:20:51 UTC (rev 322158) +++ pecl/amqp/trunk/amqp_exchange.c 2012-01-13 01:48:30 UTC (rev 322159) @@ -49,11 +49,9 @@ /* Get the envelope object from which to read */ amqp_exchange_object *exchange = (amqp_exchange_object *)zend_object_store_get_object(object TSRMLS_CC); - if (exchange->debug_info) { - zend_hash_destroy(exchange->debug_info); - efree(exchange->debug_info); - } - + /* Super magic make shit work variable. Seriously though, without this using print_r and/or var_dump will either cause memory leak or crash. */ + *is_temp = 1; + /* Keep the first number matching the number of entries in this table*/ ALLOC_HASHTABLE(exchange->debug_info); ZEND_INIT_SYMTABLE_EX(exchange->debug_info, 5 + 1, 0); @@ -94,11 +92,6 @@ if (exchange->arguments) { zval_ptr_dtor(&exchange->arguments); } - - if (exchange->debug_info) { - zend_hash_destroy(exchange->debug_info); - efree(exchange->debug_info); - } zend_object_std_dtor(&exchange->zo TSRMLS_CC); Modified: pecl/amqp/trunk/amqp_queue.c =================================================================== --- pecl/amqp/trunk/amqp_queue.c 2012-01-13 01:20:51 UTC (rev 322158) +++ pecl/amqp/trunk/amqp_queue.c 2012-01-13 01:48:30 UTC (rev 322159) @@ -49,10 +49,8 @@ /* Get the envelope object from which to read */ amqp_queue_object *queue = (amqp_queue_object *)zend_object_store_get_object(object TSRMLS_CC); - if (queue->debug_info) { - zend_hash_destroy(queue->debug_info); - efree(queue->debug_info); - } + /* Super magic make shit work variable. Seriously though, without this using print_r and/or var_dump will either cause memory leak or crash. */ + *is_temp = 1; /* Keep the # 18 matching the number of entries in this table*/ ALLOC_HASHTABLE(queue->debug_info); @@ -104,11 +102,6 @@ if (queue->arguments) { zval_ptr_dtor(&queue->arguments); } - - if (queue->debug_info) { - zend_hash_destroy(queue->debug_info); - efree(queue->debug_info); - } zend_object_std_dtor(&queue->zo TSRMLS_CC);

« previous php.pecl.cvs (#17452) next »