diff options
| author | Ilia Alshanetsky <iliaa@php.net> | 2008-12-10 20:53:44 +0000 | 
|---|---|---|
| committer | Ilia Alshanetsky <iliaa@php.net> | 2008-12-10 20:53:44 +0000 | 
| commit | 0f51787f74f91d6163ef1f32f6c5756226c10a97 (patch) | |
| tree | e0d5900b6205ce62e40167d74384b9eafcd7a188 /ext/mssql/php_mssql.c | |
| parent | fdb9b62cef6eebf0e941b17f60bef30364c7fcdb (diff) | |
| download | php-git-0f51787f74f91d6163ef1f32f6c5756226c10a97.tar.gz | |
Fixed bug #46798 (Crash in mssql extension when retrieving a NULL value
inside a binary or image column type)
Diffstat (limited to 'ext/mssql/php_mssql.c')
| -rw-r--r-- | ext/mssql/php_mssql.c | 13 | 
1 files changed, 8 insertions, 5 deletions
| diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c index 5ad9bc31bd..6dbc0d4d3e 100644 --- a/ext/mssql/php_mssql.c +++ b/ext/mssql/php_mssql.c @@ -977,11 +977,14 @@ static void php_mssql_get_column_content_with_type(mssql_link *mssql_ptr,int off  			unsigned char *res_buf;  			int res_length = dbdatlen(mssql_ptr->link, offset); -			res_buf = (unsigned char *) emalloc(res_length+1); -			bin = ((DBBINARY *)dbdata(mssql_ptr->link, offset)); -			memcpy(res_buf,bin,res_length); -			res_buf[res_length] = '\0'; -			ZVAL_STRINGL(result, res_buf, res_length, 0); +			if (!res_length) { +				ZVAL_NULL(result); +			} else { +				bin = ((DBBINARY *)dbdata(mssql_ptr->link, offset)); +				res_buf = (unsigned char *) emalloc(res_length+1); +				memcpy(res_buf,bin,res_length); +				res_buf[res_length] = '\0'; +				ZVAL_STRINGL(result, res_buf, res_length, 0);  			}  			break;  		case SQLNUMERIC: | 
