]> granicus.if.org Git - php/commitdiff
no need to call zend_is_callable() if callable is known to be invalid
authorAntony Dovgal <tony2001@php.net>
Tue, 30 May 2006 09:46:59 +0000 (09:46 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 30 May 2006 09:46:59 +0000 (09:46 +0000)
free fname on failure and plug possible leak

ext/pdo/pdo_stmt.c

index 6030fa3b9597d18fe3568d8a9bce68326577545f..de507daf82b48bc2b739841eb2ac13946d4dddde 100755 (executable)
@@ -703,8 +703,8 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
 
 static int make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info * fci, zend_fcall_info_cache * fcc, int num_args TSRMLS_DC) /* {{{ */
 {
-       zval **object = NULL, **method;
-       char *fname, *cname;
+       zval **object = NULL, **method = NULL;
+       char *fname = NULL, *cname;
        zend_class_entry * ce = NULL, **pce;
        zend_function *function_handler;
        
@@ -739,8 +739,11 @@ static int make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info *
                method = &callable;
        }
        
-       if (!zend_is_callable(callable, 0, &fname)) {
+       if (!method || !zend_is_callable(callable, 0, &fname)) {
                pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback" TSRMLS_CC);
+               if (fname) {
+                       efree(fname);
+               }
                return 0;
        }