diff options
author | Xinchen Hui <laruence@php.net> | 2014-08-14 11:52:46 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2014-08-14 11:52:46 +0800 |
commit | bfc1ae07bec3bda6dc0522da50b35ba093d4247c (patch) | |
tree | ce6d954be2be675df92a9cab7c662bc73a6491e0 /ext/odbc/php_odbc.c | |
parent | 35dd200430994b1b2807633e5d5dd3370b59633e (diff) | |
parent | 73fe4186370d8ca8bd0b8a4a8f995852cb42fa75 (diff) | |
download | php-git-bfc1ae07bec3bda6dc0522da50b35ba093d4247c.tar.gz |
Merge branch 'phpng' of https://git.php.net/repository/php-src into phpng
Diffstat (limited to 'ext/odbc/php_odbc.c')
-rw-r--r-- | ext/odbc/php_odbc.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 5fb5990050..10384da2ad 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -2954,7 +2954,7 @@ static void php_odbc_lasterror(INTERNAL_FUNCTION_PARAMETERS, int mode) { odbc_connection *conn; zval *pv_handle; - char *ptr; + zend_string *ptr; int len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &pv_handle) == FAILURE) { @@ -2969,23 +2969,21 @@ static void php_odbc_lasterror(INTERNAL_FUNCTION_PARAMETERS, int mode) if (ZEND_NUM_ARGS() == 1) { ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_handle, -1, "ODBC-Link", le_conn, le_pconn); - ptr = ecalloc(len + 1, 1); + ptr = STR_ALLOC(len + 1, 0); if (mode == 0) { - strlcpy(ptr, conn->laststate, len+1); + strlcpy(ptr->val, conn->laststate, len+1); } else { - strlcpy(ptr, conn->lasterrormsg, len+1); + strlcpy(ptr->val, conn->lasterrormsg, len+1); } } else { - ptr = ecalloc(len + 1, 1); + ptr = STR_ALLOC(len, 0); if (mode == 0) { - strlcpy(ptr, ODBCG(laststate), len+1); + strlcpy(ptr->val, ODBCG(laststate), len+1); } else { - strlcpy(ptr, ODBCG(lasterrormsg), len+1); + strlcpy(ptr->val, ODBCG(lasterrormsg), len+1); } } - RETVAL_STRING(ptr); - // TODO: avoid double reallocation ??? - efree(ptr); + RETVAL_STR(ptr); } /* }}} */ |