- MFH: Fixed memory leaks in createFunction and createAggregate methods

This commit is contained in:
Felipe Pena 2008-11-28 15:37:02 +00:00
parent 836dd82c8e
commit 9983e2689a
2 changed files with 32 additions and 0 deletions

View File

@ -791,6 +791,7 @@ PHP_METHOD(sqlite3, createFunction)
MAKE_STD_ZVAL(func->func);
*(func->func) = *callback_func;
zval_copy_ctor(func->func);
INIT_PZVAL(func->func);
func->argc = sql_func_num_args;
func->next = db_obj->funcs;
@ -849,10 +850,12 @@ PHP_METHOD(sqlite3, createAggregate)
MAKE_STD_ZVAL(func->step);
*(func->step) = *step_callback;
zval_copy_ctor(func->step);
INIT_PZVAL(func->step);
MAKE_STD_ZVAL(func->fini);
*(func->fini) = *fini_callback;
zval_copy_ctor(func->fini);
INIT_PZVAL(func->fini);
func->argc = sql_func_num_args;
func->next = db_obj->funcs;

View File

@ -0,0 +1,29 @@
--TEST--
SQLite3::createFunction - Basic test
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
require_once(dirname(__FILE__) . '/new_db.inc');
$func = 'strtoupper';
var_dump($db->createfunction($func, $func));
var_dump($db->querySingle('SELECT strtoupper("test")'));
$func2 = 'strtolower';
var_dump($db->createfunction($func2, $func2));
var_dump($db->querySingle('SELECT strtolower("TEST")'));
var_dump($db->createfunction($func, $func2));
var_dump($db->querySingle('SELECT strtoupper("tEst")'));
?>
--EXPECTF--
bool(true)
%string|unicode%(4) "TEST"
bool(true)
%string|unicode%(4) "test"
bool(true)
%string|unicode%(4) "test"