PHP  
 PHP_5_4
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Valgrind Report for ext/interbase/tests/006.phpt ('InterBase: binding (may take a while)')

Script

1: <?php /* $Id$ */
2:
3:     
require("interbase.inc");
4:     
5:     
ibase_connect($test_base);
6:     
7:     
ibase_query(
8:         
"create table test6 (
9:             iter        integer,
10:             v_char        char(1000),
11:             v_date      timestamp,
12:             v_decimal   decimal(12,3),
13:             v_double      double precision,
14:             v_float     float,
15:             v_integer   integer,
16:             v_numeric   numeric(4,2),
17:             v_smallint  smallint,
18:             v_varchar   varchar(10000)
19:             )"
);
20:     
ibase_query(
21:         
"create procedure add1 (arg integer)
22:         returns (result integer)
23:         as 
24:         begin
25:             result = arg +1;
26:         end"
);
27:     
ibase_commit();
28:
29:     
/* if timefmt not supported, hide error */
30:     
ini_set('ibase.timestampformat',"%m/%d/%Y %H:%M:%S");
31:
32:     echo 
"insert\n";
33:
34:     for(
$iter 0$iter 3$iter++) {
35:         
/* prepare data  */
36:         
$v_char rand_str(1000);
37:         
$v_date rand_datetime();
38:         
$v_decimal rand_number(12,3);
39:         
$v_double  rand_number(20);
40:         
$v_float   rand_number(7);
41:         
$v_integer rand_number(9,0);
42:         
$v_numeric rand_number(4,2);
43:         
$v_smallint rand_number(5) % 32767;
44:         
$v_varchar rand_str(10000);
45:
46:         
ibase_query("insert into test6
47:             (iter,v_char,v_date,v_decimal,v_double,v_float,
48:             v_integer,v_numeric,v_smallint,v_varchar)
49:             values (?,?,?,?,?,?,?,?,?,?)"
,
50:             
$iter$v_char$v_date$v_decimal$v_double$v_float,
51:             
$v_integer$v_numeric$v_smallint$v_varchar);
52:         
$sel ibase_query("select * from test6 where iter = ?"$iter);
53:
54:         
$row ibase_fetch_object($sel);
55:         if(
substr($row->V_CHAR,0,strlen($v_char)) != $v_char) {
56:             echo 
" CHAR fail:\n";
57:             echo 
" in:  $v_char\n";
58:             echo 
" out: $row->V_CHAR\n";
59:         }
60:         if(
$row->V_DATE != $v_date) {
61:             echo 
" DATE fail\n";
62:             echo 
" in:  $v_date\n";
63:             echo 
" out: $row->V_DATE\n";
64:         }
65:         if(
$row->V_DECIMAL != $v_decimal) {
66:             echo 
" DECIMAL fail\n";
67:             echo 
" in:  $v_decimal\n";
68:             echo 
" out: $row->V_DECIMAL\n";
69:         }
70:         if(
abs($row->V_DOUBLE $v_double) > abs($v_double 1E15)) {
71:             echo 
" DOUBLE fail\n";
72:             echo 
" in:  $v_double\n";
73:             echo 
" out: $row->V_DOUBLE\n";
74:         }
75:         if(
abs($row->V_FLOAT $v_float) > abs($v_float 1E7)) {
76:             echo 
" FLOAT fail\n";
77:             echo 
" in:  $v_float\n";
78:             echo 
" out: $row->V_FLOAT\n";
79:         }
80:         if(
$row->V_INTEGER != $v_integer) {
81:             echo 
" INTEGER fail\n";
82:             echo 
" in:  $v_integer\n";
83:             echo 
" out: $row->V_INTEGER\n";
84:         }
85:         if (
$row->V_NUMERIC != $v_numeric) {
86:             echo 
" NUMERIC fail\n";
87:             echo 
" in:  $v_numeric\n";
88:             echo 
" out: $row->V_NUMERIC\n";
89:         }
90:         if (
$row->V_SMALLINT != $v_smallint) {
91:             echo 
" SMALLINT fail\n";
92:             echo 
" in:  $v_smallint\n";
93:             echo 
" out: $row->V_SMALLINT\n";
94:         }
95:         if (
$row->V_VARCHAR != $v_varchar) {
96:             echo 
" VARCHAR fail:\n";
97:             echo 
" in:  $v_varchar\n";
98:             echo 
" out: $row->V_VARCHAR\n";
99:         }
100:         
ibase_free_result($sel);
101:     }
/* for($iter)*/
102:
103:     
echo "select\n";
104:     for(
$iter 0$iter 3$iter++) {
105:         
/* prepare data  */
106:         
$v_char rand_str(1000);
107:         
$v_date = (int)rand_number(10,0,0);
108:         
$v_decimal rand_number(12,3);
109:         
$v_double  rand_number(20);
110:         
$v_float   rand_number(7);
111:         
$v_integer rand_number(9,0);
112:         
$v_numeric rand_number(4,2);
113:         
$v_smallint rand_number(5) % 32767;
114:         
$v_varchar rand_str(10000);
115:
116:         
/* clear table*/
117:         
ibase_query("delete from test6");
118:
119:         
/* make one record */
120:         
ibase_query("insert into test6
121:             (iter, v_char,v_date,v_decimal,
122:             v_integer,v_numeric,v_smallint,v_varchar)
123:             values (666, '
$v_char',?,$v_decimal$v_integer,
124:             
$v_numeric$v_smallint, '$v_varchar')",$v_date);
125:
126:         
/* test all types */
127:         
if(!($sel ibase_query(
128:             
"select iter from test6 where v_char = ?"$v_char)) ||
129:             !
ibase_fetch_row($sel)) {
130:             echo 
"CHAR fail\n";
131:         }
132:         
ibase_free_result($sel);
133:         if(!(
$sel ibase_query(
134:             
"select iter from test6 where v_date = ?"$v_date)) ||
135:             !
ibase_fetch_row($sel)) {
136:             echo 
"DATE fail\n";
137:         }
138:         
ibase_free_result($sel);
139:         if(!(
$sel ibase_query(
140:             
"select iter from test6 where v_decimal = ?"$v_decimal)) ||
141:             !
ibase_fetch_row($sel)) {
142:             echo 
"DECIMAL fail\n";
143:         }
144:         
ibase_free_result($sel);
145:         if(!(
$sel ibase_query(
146:             
"select iter from test6 where v_integer = ?"$v_integer)) ||
147:             !
ibase_fetch_row($sel)) {
148:             echo 
"INTEGER fail\n";
149:         }
150:         
ibase_free_result($sel);
151:         if(!(
$sel ibase_query(
152:             
"select iter from test6 where v_numeric = ?"$v_numeric)) ||
153:             !
ibase_fetch_row($sel)) {
154:             echo 
"NUMERIC fail\n";
155:         }
156:         
ibase_free_result($sel);
157:         if(!(
$sel ibase_query(
158:             
"select iter from test6 where v_smallint = ?"$v_smallint)) ||
159:             !
ibase_fetch_row($sel)) {
160:             echo 
"SMALLINT fail\n";
161:         }
162:         
ibase_free_result($sel);
163:         if(!(
$sel ibase_query(
164:             
"select iter from test6 where v_varchar = ?"$v_varchar)) ||
165:             !
ibase_fetch_row($sel)) {
166:             echo 
"VARCHAR fail\n";
167:         }
168:         
ibase_free_result($sel);
169:         
170:     } 
/*for iter*/
171:
172:     
echo "prepare and exec insert\n";
173:
174:     
/* prepare table */
175:     
ibase_query("delete from test6");
176:
177:     
/* prepare query */
178:     
$query ibase_prepare(
179:         
"insert into test6 (v_integer) values (?)");
180:
181:     for(
$i 0$i 10$i++) {
182:         
ibase_execute($query$i);
183:     }
184:
185:     
out_table("test6");
186:
187:     
ibase_free_query($query);
188:
189:     echo 
"prepare and exec select\n";
190:
191:     
/* prepare query */
192:     
$query ibase_prepare("select * from test6
193:         where v_integer between ? and ?"
);
194:
195:     
$low_border 2;
196:     
$high_border 6;
197:
198:     
$res ibase_execute($query$low_border$high_border);
199:     
out_result($res"test6");
200:     
ibase_free_result($res);
201:
202:     
$low_border 0;
203:     
$high_border 4;
204:     
$res ibase_execute($query$low_border$high_border);
205:     
out_result($res"test6");
206:     
ibase_free_result($res);
207:
208:     
$res ibase_execute($query"5"7.499);
209:     
out_result($res"test6");
210:     
ibase_free_result($res);
211:
212:     
ibase_free_query($query);
213:
214:     
/* test execute procedure */
215:     
$query ibase_prepare("execute procedure add1(?)");
216:     
$res = array();
217:     for (
$i 0$i 10$i++) {
218:         
$res[] = ibase_execute($query,$i);
219:     }
220:     
ibase_free_query($query);
221:     foreach (
$res as $r) {
222:         
out_result($r"proc add1");
223:         
ibase_free_result($r);
224:     }
225:
226:     
ibase_close();
227:     echo 
"end of test\n";
228:
?>
229:

Report

==6370== Invalid write of size 8
==6370==    at 0x77207F: _php_ibase_free_result (ibase_query.c:146)
==6370==    by 0xDA0670: list_entry_destructor (zend_list.c:183)
==6370==    by 0xD9BA83: zend_hash_del_key_or_index (zend_hash.c:531)
==6370==    by 0xD9FE19: _zend_list_delete (zend_list.c:57)
==6370==    by 0x778805: zif_ibase_free_result (ibase_query.c:1724)
==6370==    by 0xDE095B: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:643)
==6370==    by 0xDEAAFB: ZEND_DO_FCALL_SPEC_CONST_HANDLER (zend_vm_execute.h:2233)
==6370==    by 0xDDEAB7: execute (zend_vm_execute.h:410)
==6370==    by 0xD82A54: zend_execute_scripts (zend.c:1315)
==6370==    by 0xCB4DE9: php_execute_script (main.c:2502)
==6370==    by 0xF50AD0: do_cli (php_cli.c:989)
==6370==    by 0xF5210D: main (php_cli.c:1365)
==6370==  Address 0x14ce4400 is 16 bytes inside a block of size 88 free'd
==6370==    at 0x4C274D4: free (vg_replace_malloc.c:468)
==6370==    by 0xD35615: _efree (zend_alloc.c:2433)
==6370==    by 0x772324: php_ibase_free_query_rsrc (ibase_query.c:190)
==6370==    by 0xDA0670: list_entry_destructor (zend_list.c:183)
==6370==    by 0xD9BA83: zend_hash_del_key_or_index (zend_hash.c:531)
==6370==    by 0xD9FE19: _zend_list_delete (zend_list.c:57)
==6370==    by 0x7793A9: zif_ibase_free_query (ibase_query.c:1871)
==6370==    by 0xDE095B: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:643)
==6370==    by 0xDEAAFB: ZEND_DO_FCALL_SPEC_CONST_HANDLER (zend_vm_execute.h:2233)
==6370==    by 0xDDEAB7: execute (zend_vm_execute.h:410)
==6370==    by 0xD82A54: zend_execute_scripts (zend.c:1315)
==6370==    by 0xCB4DE9: php_execute_script (main.c:2502)
==6370== 

 

Generated at Sun, 20 Apr 2014 03:52:23 +0000 (3 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.