cvs: php-src /ext/mssql php_mssql.c
| From: | Ilia Alshanetsky | Date: | Wed, 10 Dec 2008 20:53:58 +0000 |
| Subject: | cvs: php-src /ext/mssql php_mssql.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-54843@lists.php.net to get a copy of this message | ||
iliaa Wed Dec 10 20:53:58 2008 UTC
Modified files:
/php-src/ext/mssql php_mssql.c
Log:
MFB: Fixed bug #46798 (Crash in mssql extension when retrieving a NULL value
inside a binary or image column type)
http://cvs.php.net/viewvc.cgi/php-src/ext/mssql/php_mssql.c?r1=1.182&r2=1.183&diff_format=u
Index: php-src/ext/mssql/php_mssql.c
diff -u php-src/ext/mssql/php_mssql.c:1.182 php-src/ext/mssql/php_mssql.c:1.183
--- php-src/ext/mssql/php_mssql.c:1.182 Mon Nov 17 11:26:22 2008
+++ php-src/ext/mssql/php_mssql.c Wed Dec 10 20:53:58 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mssql.c,v 1.182 2008/11/17 11:26:22 felipe Exp $ */
+/* $Id: php_mssql.c,v 1.183 2008/12/10 20:53:58 iliaa Exp $ */
#ifdef COMPILE_DL_MSSQL
#define HAVE_MSSQL 1
@@ -977,11 +977,14 @@
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: