]> granicus.if.org Git - php/commitdiff
Avoid incomplete zend_internal_function initialization.
authorDmitry Stogov <dmitry@zend.com>
Wed, 13 Jan 2016 12:06:17 +0000 (15:06 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 13 Jan 2016 12:06:17 +0000 (15:06 +0300)
ext/pdo/pdo_dbh.c

index cc6346bf152bdd234ae09e46846d000c3c483561..886a672303789b68a1864df570f618019a85f417 100644 (file)
@@ -1274,8 +1274,7 @@ static void cls_method_pdtor(zval *el) /* {{{ */ {
 int pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind)
 {
        const zend_function_entry *funcs;
-       zend_function func;
-       zend_internal_function *ifunc = (zend_internal_function*)&func;
+       zend_internal_function func;
        size_t namelen;
        char *lc_name;
        pdo_dbh_t *dbh = dbh_obj->inner;
@@ -1294,41 +1293,43 @@ int pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind)
        zend_hash_init_ex(dbh->cls_methods[kind], 8, NULL,
                        dbh->is_persistent? cls_method_pdtor : cls_method_dtor, dbh->is_persistent, 0);
 
+       memset(&func, 0, sizeof(func));
+
        while (funcs->fname) {
-               ifunc->type = ZEND_INTERNAL_FUNCTION;
-               ifunc->handler = funcs->handler;
-               ifunc->function_name = zend_string_init(funcs->fname, strlen(funcs->fname), dbh->is_persistent);
-               ifunc->scope = dbh_obj->std.ce;
-               ifunc->prototype = NULL;
+               func.type = ZEND_INTERNAL_FUNCTION;
+               func.handler = funcs->handler;
+               func.function_name = zend_string_init(funcs->fname, strlen(funcs->fname), dbh->is_persistent);
+               func.scope = dbh_obj->std.ce;
+               func.prototype = NULL;
                if (funcs->flags) {
-                       ifunc->fn_flags = funcs->flags | ZEND_ACC_NEVER_CACHE;
+                       func.fn_flags = funcs->flags | ZEND_ACC_NEVER_CACHE;
                } else {
-                       ifunc->fn_flags = ZEND_ACC_PUBLIC | ZEND_ACC_NEVER_CACHE;
+                       func.fn_flags = ZEND_ACC_PUBLIC | ZEND_ACC_NEVER_CACHE;
                }
                if (funcs->arg_info) {
                        zend_internal_function_info *info = (zend_internal_function_info*)funcs->arg_info;
 
-                       ifunc->arg_info = (zend_internal_arg_info*)funcs->arg_info + 1;
-                       ifunc->num_args = funcs->num_args;
+                       func.arg_info = (zend_internal_arg_info*)funcs->arg_info + 1;
+                       func.num_args = funcs->num_args;
                        if (info->required_num_args == -1) {
-                               ifunc->required_num_args = funcs->num_args;
+                               func.required_num_args = funcs->num_args;
                        } else {
-                               ifunc->required_num_args = info->required_num_args;
+                               func.required_num_args = info->required_num_args;
                        }
                        if (info->return_reference) {
-                               ifunc->fn_flags |= ZEND_ACC_RETURN_REFERENCE;
+                               func.fn_flags |= ZEND_ACC_RETURN_REFERENCE;
                        }
                        if (funcs->arg_info[funcs->num_args].is_variadic) {
-                               ifunc->fn_flags |= ZEND_ACC_VARIADIC;
+                               func.fn_flags |= ZEND_ACC_VARIADIC;
                                /* Don't count the variadic argument */
-                               ifunc->num_args--;
+                               func.num_args--;
                        }
                } else {
-                       ifunc->arg_info = NULL;
-                       ifunc->num_args = 0;
-                       ifunc->required_num_args = 0;
+                       func.arg_info = NULL;
+                       func.num_args = 0;
+                       func.required_num_args = 0;
                }
-               zend_set_function_arg_flags((zend_function*)ifunc);
+               zend_set_function_arg_flags(&func);
                namelen = strlen(funcs->fname);
                lc_name = emalloc(namelen+1);
                zend_str_tolower_copy(lc_name, funcs->fname, namelen);