iliaa           Wed Dec 10 20:53:44 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/mssql  php_mssql.c 
  Log:
  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.152.2.13.2.4.2.14&r2=1.152.2.13.2.4.2.15&diff_format=u
Index: php-src/ext/mssql/php_mssql.c
diff -u php-src/ext/mssql/php_mssql.c:1.152.2.13.2.4.2.14 
php-src/ext/mssql/php_mssql.c:1.152.2.13.2.4.2.15
--- php-src/ext/mssql/php_mssql.c:1.152.2.13.2.4.2.14   Mon Nov 17 11:27:56 2008
+++ php-src/ext/mssql/php_mssql.c       Wed Dec 10 20:53:44 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_mssql.c,v 1.152.2.13.2.4.2.14 2008/11/17 11:27:56 felipe Exp $ */
+/* $Id: php_mssql.c,v 1.152.2.13.2.4.2.15 2008/12/10 20:53:44 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:



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to