mirror of
https://github.com/php/php-src.git
synced 2024-12-11 10:54:47 +08:00
- MFH: Fixed memory leaks in createFunction and createAggregate methods
This commit is contained in:
parent
836dd82c8e
commit
9983e2689a
@ -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;
|
||||
|
29
ext/sqlite3/tests/sqlite3_29_createfunction.phpt
Normal file
29
ext/sqlite3/tests/sqlite3_29_createfunction.phpt
Normal 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"
|
Loading…
Reference in New Issue
Block a user