From 212bd7cdc7d64426b4b9ea136ae3d7cad4ef8e56 Mon Sep 17 00:00:00 2001 From: Kisoo Han Date: Wed, 20 Dec 2017 16:25:27 +0900 Subject: [PATCH] Revert "modified cubrid_close, fetch_cubrid_connect, and php_cubrid_fetch_hash for correction (#19)" This reverts commit 16498371e17fbeb3e7751e039ebb2764a4e83d67. --- php_cubrid7.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/php_cubrid7.c b/php_cubrid7.c index c19a89d..80caff2 100644 --- a/php_cubrid7.c +++ b/php_cubrid7.c @@ -1083,6 +1083,11 @@ T_CUBRID_CONNECT* fetch_cubrid_connect(zval* conn_id) } else { link = FETCH_DEFAULT_LINK(); } + CHECK_DEFAULT_LINK(link); + + if (link == NULL) { + return NULL; + } return (T_CUBRID_CONNECT*)zend_fetch_resource2(link, "CUBRID Connect", le_connect, le_pconnect); } @@ -1565,7 +1570,8 @@ ZEND_FUNCTION(cubrid_close) res_id = conn_id ? Z_RES_P(conn_id) : CUBRID_G(default_link); if (res_id) { - zend_list_close(res_id); + GC_REFCOUNT(res_id)--; + GC_REFCOUNT(res_id)--; } // On an explicit close of the default connection it had a refcount of 2, // so we need one more call @@ -6754,12 +6760,12 @@ static void php_cubrid_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long type, int i if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) { if (Z_TYPE_P(ctor_params) == IS_ARRAY) { HashTable *ht = Z_ARRVAL_P(ctor_params); - zend_ulong num_idx; - zend_string *fld; + zend_ulong num_idx; + zend_string *fld; zval *val; fci.param_count = 0; - fci.params = (zval *)safe_emalloc(ht->nNumOfElements, sizeof(zval), 0); + fci.params = (zval *)safe_emalloc(sizeof(zval*), ht->nNumOfElements, 0); ZEND_HASH_FOREACH_KEY_VAL(ht, num_idx, fld, val) { fci.params[fci.param_count++] = *val; }ZEND_HASH_FOREACH_END(); @@ -6779,7 +6785,7 @@ static void php_cubrid_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long type, int i fcc.initialized = 1; fcc.function_handler = ce->constructor; //fcc.calling_scope = EG(scope); - fcc.called_scope = Z_OBJCE_P(return_value); + fcc.called_scope = Z_OBJCE_P(return_value); fcc.object = Z_OBJ_P(return_value); if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) {