summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2003-04-30 10:46:43 +0000
committerWez Furlong <wez@php.net>2003-04-30 10:46:43 +0000
commit6454f5c3f26b320006e71eb6fde097389a4a2a12 (patch)
tree591089a18cb94f68acbe67a8b777e30a63a25cd5
parent08a657f8fa660a06865d96e8a39b2dc003522c67 (diff)
downloadphp-git-6454f5c3f26b320006e71eb6fde097389a4a2a12.tar.gz
MFH: Fix memory leak and enable for IBM DB2.
-rw-r--r--ext/odbc/php_odbc.c9
-rw-r--r--ext/odbc/php_odbc.h6
2 files changed, 10 insertions, 5 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 545346dc65..941197cbf3 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -84,7 +84,7 @@ function_entry odbc_functions[] = {
PHP_FE(odbc_error, NULL)
PHP_FE(odbc_errormsg, NULL)
PHP_FE(odbc_exec, NULL)
-#ifdef HAVE_DBMAKER
+#ifdef PHP_ODBC_HAVE_FETCH_HASH
PHP_FE(odbc_fetch_array, NULL)
PHP_FE(odbc_fetch_object, NULL)
#endif
@@ -1346,7 +1346,7 @@ PHP_FUNCTION(odbc_exec)
}
/* }}} */
-#ifdef HAVE_DBMAKER
+#ifdef PHP_ODBC_HAVE_FETCH_HASH
#define ODBC_NUM 1
#define ODBC_OBJECT 2
@@ -1414,6 +1414,8 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
RETURN_FALSE;
}
+ array_init(return_value);
+
#ifdef HAVE_SQL_EXTENDED_FETCH
if (rownum > 0 && result->fetch_abs)
result->fetched = rownum;
@@ -1422,8 +1424,7 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
result->fetched++;
for(i = 0; i < result->numcols; i++) {
- ALLOC_ZVAL(tmp);
- tmp->refcount = 1;
+ ALLOC_INIT_ZVAL(tmp);
Z_TYPE_P(tmp) = IS_STRING;
Z_STRLEN_P(tmp) = 0;
sql_c_type = SQL_C_CHAR;
diff --git a/ext/odbc/php_odbc.h b/ext/odbc/php_odbc.h
index 8c2cafe32e..eeda8fb9a4 100644
--- a/ext/odbc/php_odbc.h
+++ b/ext/odbc/php_odbc.h
@@ -33,6 +33,10 @@
extern zend_module_entry odbc_module_entry;
#define odbc_module_ptr &odbc_module_entry
+#if defined(HAVE_DBMAKER) || defined(PHP_WIN32) || defined(HAVE_IBMDB2)
+# define PHP_ODBC_HAVE_FETCH_HASH 1
+#endif
+
/* user functions */
PHP_MINIT_FUNCTION(odbc);
PHP_MSHUTDOWN_FUNCTION(odbc);
@@ -54,7 +58,7 @@ PHP_FUNCTION(odbc_data_source);
PHP_FUNCTION(odbc_do);
PHP_FUNCTION(odbc_exec);
PHP_FUNCTION(odbc_execute);
-#ifdef HAVE_DBMAKER
+#ifdef PHP_ODBC_HAVE_FETCH_HASH
PHP_FUNCTION(odbc_fetch_array);
PHP_FUNCTION(odbc_fetch_object);
#endif