diff options
author | Frank M. Kromann <fmk@php.net> | 2005-11-18 20:41:03 +0000 |
---|---|---|
committer | Frank M. Kromann <fmk@php.net> | 2005-11-18 20:41:03 +0000 |
commit | 4701b2f73b597566af5d421b0a8e4ddc6d1c0dfd (patch) | |
tree | 3b89b2726126724316c30ed663b266a35f957821 | |
parent | 78803108337473e3d2102b58b3128a8d0079b6b1 (diff) | |
download | php-git-4701b2f73b597566af5d421b0a8e4ddc6d1c0dfd.tar.gz |
MFH: Fix #32009 crash when mssql_bind() is called more than once
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/mssql/php_mssql.c | 27 |
2 files changed, 17 insertions, 11 deletions
@@ -59,6 +59,7 @@ PHP NEWS - Fixed bug #32179 (xmlrpc_encode() segfaults with recursive references). (Tony) - Fixed bug #29983 (PHP does not explicitly set mime type & charset). (Ilia) - Fixed bug #33153 (crash in mssql_next result). (Frank) +- Fixed bug #32009 (crash when mssql_bind() is called more than once). (Frank) 05 Sep 2005, PHP 5.0.5 - Upgraded PCRE library to version 5.0. (Andrei) diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c index ec57ef19ce..853a7868dd 100644 --- a/ext/mssql/php_mssql.c +++ b/ext/mssql/php_mssql.c @@ -2083,17 +2083,22 @@ PHP_FUNCTION(mssql_bind) zend_hash_init(statement->binds, 13, NULL, _mssql_bind_hash_dtor, 0); } - memset((void*)&bind,0,sizeof(mssql_bind)); - zend_hash_add(statement->binds,Z_STRVAL_PP(param_name),Z_STRLEN_PP(param_name),&bind,sizeof(mssql_bind),(void **)&bindp); - if( NULL == bindp ) RETURN_FALSE; - bindp->zval=*var; - zval_add_ref(var); - - /* no call to dbrpcparam if RETVAL */ - if ( strcmp("RETVAL",Z_STRVAL_PP(param_name))!=0 ) { - if (dbrpcparam(mssql_ptr->link, Z_STRVAL_PP(param_name), (BYTE)status, type, maxlen, datalen, (LPBYTE)value)==FAIL) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set parameter"); - RETURN_FALSE; + if (zend_hash_exists(statement->binds, Z_STRVAL_PP(param_name), Z_STRLEN_PP(param_name))) { + RETURN_FALSE; + } + else { + memset((void*)&bind,0,sizeof(mssql_bind)); + zend_hash_add(statement->binds, Z_STRVAL_PP(param_name), Z_STRLEN_PP(param_name), &bind, sizeof(mssql_bind), (void **)&bindp); + if( NULL == bindp ) RETURN_FALSE; + bindp->zval=*var; + zval_add_ref(var); + + /* no call to dbrpcparam if RETVAL */ + if ( strcmp("RETVAL",Z_STRVAL_PP(param_name))!=0 ) { + if (dbrpcparam(mssql_ptr->link, Z_STRVAL_PP(param_name), (BYTE)status, type, maxlen, datalen, (LPBYTE)value)==FAIL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set parameter"); + RETURN_FALSE; + } } } |