@@ -126,8 +126,9 @@ static void _php_ibase_event_block(ibase_db_link *ib_link, unsigned short count,
126
126
Waits for any one of the passed Interbase events to be posted by the database, and returns its name */
127
127
PHP_FUNCTION (ibase_wait_event )
128
128
{
129
- zval * * args [ 16 ] ;
129
+ zval * * * args ;
130
130
ibase_db_link * ib_link ;
131
+ int num_args ;
131
132
char * event_buffer , * result_buffer , * events [15 ];
132
133
unsigned short i = 0 , event_count = 0 , buffer_size ;
133
134
unsigned long occurred_event [15 ];
@@ -139,22 +140,25 @@ PHP_FUNCTION(ibase_wait_event)
139
140
WRONG_PARAM_COUNT ;
140
141
}
141
142
142
- if (zend_get_parameters_array_ex (ZEND_NUM_ARGS (), args ) == FAILURE ) {
143
- RETURN_FALSE ;
143
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "+" , & args , & num_args ) == FAILURE ) {
144
+ return ;
144
145
}
145
146
146
147
if (Z_TYPE_PP (args [0 ]) == IS_RESOURCE ) {
147
-
148
- ZEND_FETCH_RESOURCE2 (ib_link , ibase_db_link * , args [0 ], -1 , "InterBase link" , le_link , le_plink );
148
+ if (!ZEND_FETCH_RESOURCE2_NO_RETURN (ib_link , ibase_db_link * , args [0 ], -1 , "InterBase link" , le_link , le_plink )) {
149
+ efree (args );
150
+ RETURN_FALSE ;
151
+ }
149
152
i = 1 ;
150
-
151
153
} else {
152
-
153
154
if (ZEND_NUM_ARGS () > 15 ) {
155
+ efree (args );
154
156
WRONG_PARAM_COUNT ;
155
157
}
156
-
157
- ZEND_FETCH_RESOURCE2 (ib_link , ibase_db_link * , NULL , IBG (default_link ), "InterBase link" , le_link , le_plink );
158
+ if (!ZEND_FETCH_RESOURCE2_NO_RETURN (ib_link , ibase_db_link * , NULL , IBG (default_link ), "InterBase link" , le_link , le_plink )) {
159
+ efree (args );
160
+ RETURN_FALSE ;
161
+ }
158
162
}
159
163
160
164
for (; i < ZEND_NUM_ARGS (); ++ i ) {
@@ -169,6 +173,7 @@ PHP_FUNCTION(ibase_wait_event)
169
173
if (isc_wait_for_event (IB_STATUS , & ib_link -> handle , buffer_size , event_buffer , result_buffer )) {
170
174
_php_ibase_error (TSRMLS_C );
171
175
_php_ibase_event_free (event_buffer ,result_buffer );
176
+ efree (args );
172
177
RETURN_FALSE ;
173
178
}
174
179
@@ -178,13 +183,15 @@ PHP_FUNCTION(ibase_wait_event)
178
183
if (occurred_event [i ]) {
179
184
char * result = estrdup (events [i ]);
180
185
_php_ibase_event_free (event_buffer ,result_buffer );
186
+ efree (args );
181
187
RETURN_STRING (result ,0 );
182
188
}
183
189
}
184
190
185
191
/* If we reach this line, isc_wait_for_event() did return, but we don't know
186
192
which event fired. */
187
193
_php_ibase_event_free (event_buffer ,result_buffer );
194
+ efree (args );
188
195
RETURN_FALSE ;
189
196
}
190
197
/* }}} */
@@ -261,11 +268,11 @@ PHP_FUNCTION(ibase_set_event_handler)
261
268
* used to determine if the event handler should remain set.
262
269
*/
263
270
char * cb_name ;
264
- zval * * args [ 17 ] , * * cb_arg ;
271
+ zval * * * args , * * cb_arg ;
265
272
ibase_db_link * ib_link ;
266
273
ibase_event * event ;
267
274
unsigned short i = 1 , buffer_size ;
268
- int link_res_id ;
275
+ int link_res_id , num_args ;
269
276
270
277
RESET_ERRMSG ;
271
278
@@ -274,8 +281,8 @@ PHP_FUNCTION(ibase_set_event_handler)
274
281
WRONG_PARAM_COUNT ;
275
282
}
276
283
277
- if (zend_get_parameters_array_ex (ZEND_NUM_ARGS (), args ) == FAILURE ) {
278
- RETURN_FALSE ;
284
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "+" , & args , & num_args ) == FAILURE ) {
285
+ return ;
279
286
}
280
287
281
288
/* get a working link */
@@ -284,14 +291,17 @@ PHP_FUNCTION(ibase_set_event_handler)
284
291
* No more than 15 events
285
292
*/
286
293
if (ZEND_NUM_ARGS () < 3 || ZEND_NUM_ARGS () > 17 ) {
294
+ efree (args );
287
295
WRONG_PARAM_COUNT ;
288
296
}
289
297
290
298
cb_arg = args [1 ];
291
299
i = 2 ;
292
300
293
- ZEND_FETCH_RESOURCE2 (ib_link , ibase_db_link * , args [0 ], -1 ,
294
- "InterBase link" , le_link , le_plink );
301
+ if (!ZEND_FETCH_RESOURCE2_NO_RETURN (ib_link , ibase_db_link * , args [0 ], -1 , "InterBase link" , le_link , le_plink )) {
302
+ efree (args );
303
+ RETURN_FALSE ;
304
+ }
295
305
296
306
convert_to_long_ex (args [0 ]);
297
307
link_res_id = Z_LVAL_PP (args [0 ]);
@@ -301,20 +311,24 @@ PHP_FUNCTION(ibase_set_event_handler)
301
311
* No more than 15 events
302
312
*/
303
313
if (ZEND_NUM_ARGS () < 2 || ZEND_NUM_ARGS () > 16 ) {
314
+ efree (args );
304
315
WRONG_PARAM_COUNT ;
305
316
}
306
317
307
318
cb_arg = args [0 ];
308
319
309
- ZEND_FETCH_RESOURCE2 (ib_link , ibase_db_link * , NULL , IBG (default_link ),
310
- "InterBase link" , le_link , le_plink );
320
+ if (!ZEND_FETCH_RESOURCE2_NO_RETURN (ib_link , ibase_db_link * , NULL , IBG (default_link ), "InterBase link" , le_link , le_plink )) {
321
+ efree (args );
322
+ RETURN_FALSE ;
323
+ }
311
324
link_res_id = IBG (default_link );
312
325
}
313
326
314
327
/* get the callback */
315
328
if (!zend_is_callable (* cb_arg , 0 , & cb_name TSRMLS_CC )) {
316
329
_php_ibase_module_error ("Callback argument %s is not a callable function" TSRMLS_CC , cb_name );
317
330
efree (cb_name );
331
+ efree (args );
318
332
RETURN_FALSE ;
319
333
}
320
334
efree (cb_name );
@@ -348,6 +362,7 @@ PHP_FUNCTION(ibase_set_event_handler)
348
362
349
363
_php_ibase_error (TSRMLS_C );
350
364
efree (event );
365
+ efree (args );
351
366
RETURN_FALSE ;
352
367
}
353
368
@@ -356,6 +371,7 @@ PHP_FUNCTION(ibase_set_event_handler)
356
371
357
372
ZEND_REGISTER_RESOURCE (return_value , event , le_event );
358
373
zend_list_addref (Z_LVAL_P (return_value ));
374
+ efree (args );
359
375
}
360
376
/* }}} */
361
377
0 commit comments