Skip to content
Browse files

Fixed bug #46798 (Crash in mssql extension when retrieving a NULL value

inside a binary or image column type)
  • Loading branch information...
1 parent fdb9b62 commit 0f51787f74f91d6163ef1f32f6c5756226c10a97 Ilia Alshanetsky committed Dec 10, 2008
Showing with 8 additions and 5 deletions.
  1. +8 −5 ext/mssql/php_mssql.c
View
13 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:

0 comments on commit 0f51787

Please sign in to comment.
Something went wrong with that request. Please try again.