summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2005-01-17 15:05:11 +0000
committerAntony Dovgal <tony2001@php.net>2005-01-17 15:05:11 +0000
commitacbdbe1e657ae954c24513b21be3ba46cf44fe4e (patch)
treedd30e20c450f099a65095a5b72bfc0786f31a8a1
parent8288c451c0981147a65efd600c5e01bce27d4bc7 (diff)
downloadphp-git-acbdbe1e657ae954c24513b21be3ba46cf44fe4e.tar.gz
fix leak appearing when odbc_errormsg() got invalid resource
-rw-r--r--ext/odbc/php_odbc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 438204f21c..6020959e4f 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -2712,15 +2712,17 @@ static void php_odbc_lasterror(INTERNAL_FUNCTION_PARAMETERS, int mode)
} else { /* last error message */
len = SQL_MAX_MESSAGE_LENGTH;
}
- ptr = ecalloc(len + 1, 1);
+
if (argc == 1) {
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_handle, -1, "ODBC-Link", le_conn, le_pconn);
+ ptr = ecalloc(len + 1, 1);
if (mode == 0) {
strlcpy(ptr, conn->laststate, len+1);
} else {
strlcpy(ptr, conn->lasterrormsg, len+1);
}
} else {
+ ptr = ecalloc(len + 1, 1);
if (mode == 0) {
strlcpy(ptr, ODBCG(laststate), len+1);
} else {