]> granicus.if.org Git - php/commitdiff
Fixed possible crash in php_mssql_get_column_content_without_type()
authorKalle Sommer Nielsen <kalle@php.net>
Wed, 18 Aug 2010 20:16:05 +0000 (20:16 +0000)
committerKalle Sommer Nielsen <kalle@php.net>
Wed, 18 Aug 2010 20:16:05 +0000 (20:16 +0000)
# Also fix NEWS entry in PHP_5_2 for previous commit

ext/mssql/php_mssql.c

index aaee1d2789a9394fc5dd7c1c6238f324a6ad2353..17e698cead36aadae90cd76a70a83cc4cf594ae6 100644 (file)
@@ -1059,6 +1059,14 @@ static void php_mssql_get_column_content_without_type(mssql_link *mssql_ptr,int
                unsigned char *res_buf;
                int res_length = dbdatlen(mssql_ptr->link, offset);
 
+               if (res_length == 0) {
+                       ZVAL_NULL(result);
+                       return;
+               } else if (res_length < 0) {
+                       ZVAL_FALSE(result);
+                       return;
+               }
+
                res_buf = (unsigned char *) emalloc(res_length+1);
                bin = ((DBBINARY *)dbdata(mssql_ptr->link, offset));
                res_buf[res_length] = '\0';