]> granicus.if.org Git - php/commitdiff
More PHP 7 patches (Rajendra/Abdullah)
authorChristopher Jones <christopher.jones@oracle.com>
Tue, 30 Jun 2015 03:54:40 +0000 (13:54 +1000)
committerChristopher Jones <christopher.jones@oracle.com>
Tue, 30 Jun 2015 03:54:40 +0000 (13:54 +1000)
ext/oci8/oci8.c
ext/oci8/oci8_interface.c
ext/oci8/oci8_statement.c

index 0492cdb238987dbc3be456d78066ac4eba29a74a..f431dcaba9a7775b69298f11aee36e190904c5f3 100644 (file)
@@ -1562,8 +1562,8 @@ void php_oci_bind_hash_dtor(zval *data)
        if (bind->array.indicators) {
                efree(bind->array.indicators);
        }
-
-       zval_ptr_dtor(&bind->zval);
+       efree(bind);
+       /*zval_ptr_dtor(&bind->zval); */
 }
 /* }}} */
 
@@ -1590,6 +1590,8 @@ void php_oci_column_hash_dtor(zval *data)
        if (column->name) {
                efree(column->name);
        }
+
+       efree(column);
 }
 /* }}} */
 
index 4deaec608087d15d302295cceb10545d61da2bae..bccab92a482a30a5956beac6384d145f19e2a308 100644 (file)
@@ -55,6 +55,7 @@ PHP_FUNCTION(oci_define_by_name)
        zend_long type = 0;
        php_oci_statement *statement;
        php_oci_define *define, *tmp_define;
+       zend_string *zvtmp;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsz/|l", &stmt, &name, &name_len, &var, &type) == FAILURE) {
                return;
@@ -74,12 +75,15 @@ PHP_FUNCTION(oci_define_by_name)
 
        define = ecalloc(1,sizeof(php_oci_define));
 
-       //if (zend_hash_add(statement->defines, name, name_len, define, sizeof(php_oci_define), (void **)&tmp_define) == SUCCESS) {
-       if ((tmp_define = zend_hash_add_new_ptr(statement->defines, zend_string_init(name, name_len, 0), define)) != NULL) {
+       /* if (zend_hash_add(statement->defines, name, name_len, define, sizeof(php_oci_define), (void **)&tmp_define) == SUCCESS) { */
+       zvtmp = zend_string_init(name, name_len, 0);
+       if ((tmp_define = zend_hash_add_new_ptr(statement->defines, zvtmp, define)) != NULL) {
                efree(define);
+               zend_string_release(zvtmp);
                define = tmp_define;
        } else {
                efree(define);
+               zend_string_release(zvtmp);
                RETURN_FALSE;
        }
 
@@ -1429,7 +1433,10 @@ PHP_FUNCTION(oci_fetch_all)
                                if (flags & PHP_OCI_NUM) {
                                        zend_hash_next_index_insert(Z_ARRVAL(row), &element);
                                } else { /* default to ASSOC */
-                                       zend_symtable_update(Z_ARRVAL(row), zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0), &element);
+                                       zend_string *zvtmp;
+                                       zvtmp = zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0);
+                                       zend_symtable_update(Z_ARRVAL(row), zvtmp, &element);
+                                       zend_string_release(zvtmp);
                                }
                        }
 
@@ -1456,10 +1463,13 @@ PHP_FUNCTION(oci_fetch_all)
                        }
                } else { /* default to ASSOC */
                        for (i = 0; i < statement->ncolumns; i++) {
+                               zend_string *zvtmp;
                                columns[ i ] = php_oci_statement_get_column(statement, i + 1, NULL, 0);
                                
                                array_init(&tmp);
-                               outarrs[ i ] = zend_symtable_update(Z_ARRVAL_P(array), zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0), &tmp);
+                               zvtmp = zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0);
+                               outarrs[ i ] = zend_symtable_update(Z_ARRVAL_P(array), zvtmp, &tmp);
+                               zend_string_release(zvtmp);
                        }
                }
 
@@ -1657,7 +1667,7 @@ go_out:
        if (errcode) {
                array_init(return_value);
                add_assoc_long(return_value, "code", errcode);
-               // TODO: avoid reallocation ???
+               /* TODO: avoid reallocation ??? */
                add_assoc_string(return_value, "message", (char*) errbuf);
                efree(errbuf);
                add_assoc_long(return_value, "offset", error_offset);
index ef68f1ce38fe11e835924d21e1a6b685d06c5fb4..3f5e826a7bb442395c2c29309c1eb186674595cf 100644 (file)
@@ -589,7 +589,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode)
                        outcol = (php_oci_out_column *) ecalloc(1, sizeof(php_oci_out_column));
                        
                        if ((outcol = zend_hash_index_update_ptr(statement->columns, counter, outcol)) == NULL) {
-                               efree(statement->columns);
+                               FREE_HASHTABLE(statement->columns);
                                /* out of memory */
                                return 1;
                        }
@@ -875,17 +875,17 @@ void php_oci_statement_free(php_oci_statement *statement)
 
        if (statement->columns) {
                zend_hash_destroy(statement->columns);
-               efree(statement->columns);
+               FREE_HASHTABLE(statement->columns);
        }
 
        if (statement->binds) {
                zend_hash_destroy(statement->binds);
-               efree(statement->binds);
+               FREE_HASHTABLE(statement->binds);
        }
 
        if (statement->defines) {
                zend_hash_destroy(statement->defines);
-               efree(statement->defines);
+               FREE_HASHTABLE(statement->defines);
        }
 
        if (statement->parent_stmtid) {
@@ -1210,12 +1210,15 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
                zend_hash_init(statement->binds, 13, NULL, php_oci_bind_hash_dtor, 0);
        }
 
-       memset((void*)&bind,0,sizeof(php_oci_bind));
        if ((old_bind = zend_hash_str_find_ptr(statement->binds, name, name_len)) != NULL) {
                bindp = old_bind;
                zval_ptr_dtor(&bindp->zval);
        } else {
-               bindp = zend_hash_update_ptr(statement->binds, zend_string_init(name, name_len + 1, 0), &bind);
+               zend_string *zvtmp;
+               zvtmp = zend_string_init(name, name_len + 1, 0);
+               bindp = (php_oci_bind *) ecalloc(1, sizeof(php_oci_bind));
+               bindp = zend_hash_update_ptr(statement->binds, zvtmp, bindp);
+               zend_string_release(zvtmp);
        }
        
        bindp->descriptor = oci_desc;
@@ -1223,7 +1226,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
        bindp->parent_statement = statement;
        ZVAL_COPY(&bindp->zval, var);
        bindp->type = type;
-       Z_ADDREF_P(var);
+       Z_TRY_ADDREF_P(var);
        
        PHP_OCI_CALL_RETURN(errstatus,
                OCIBindByName,
@@ -1407,10 +1410,12 @@ sb4 php_oci_bind_out_callback(
        } else {
                convert_to_string(val);
                zval_dtor(val);
-               
-               //Z_STRLEN_P(val) = PHP_OCI_PIECE_SIZE; /* 64K-1 is max XXX */
-               //Z_STRVAL_P(val) = ecalloc(1, Z_STRLEN_P(phpbind->zval) + 1);
-               // XXX is this right?
+
+#if 0          
+               Z_STRLEN_P(val) = PHP_OCI_PIECE_SIZE; /* 64K-1 is max XXX */
+               Z_STRVAL_P(val) = ecalloc(1, Z_STRLEN_P(phpbind->zval) + 1);
+               /* XXX is this right? */
+#endif         
                ZVAL_STRINGL(val, NULL, Z_STRLEN(phpbind->zval) + 1);
 
                /* XXX we assume that zend-zval len has 4 bytes */
@@ -1524,6 +1529,7 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam
 {
        php_oci_bind *bind, *bindp;
        sword errstatus;
+       zend_string *zvtmp;
 
        convert_to_array(var);
 
@@ -1574,7 +1580,9 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam
                zend_hash_init(statement->binds, 13, NULL, php_oci_bind_hash_dtor, 0);
        }
 
-       bindp = zend_hash_update_ptr(statement->binds, zend_string_init(name, name_len + 1, 0), bind);
+       zvtmp = zend_string_init(name, name_len + 1, 0);
+       bindp = zend_hash_update_ptr(statement->binds, zvtmp, bind);
+       zend_string_release(zvtmp);
 
        bindp->descriptor = NULL;
        bindp->statement = NULL;