msphpsql icon indicating copy to clipboard operation
msphpsql copied to clipboard

memory exception when calling sql_next_result

Open v-mabarw opened this issue 12 years ago • 1 comments

SQL serer library: php_sqlsrv.dll, version 3
PHP: 5.4 & 5.5

Hi,

When calling sql_next_result we get a memory exception. The exception is caused by the code in

_ sqlsrv_error* odbc_get_diag_rec( sqlsrv_stmt* odbc, SQLSMALLINT record_number ) _

attempting to free a stack based char buffer.

The problem occurs when convert_string_from_utf16 does not convert the SQL message (in our case a warning derived from a sql server print statement). If it is not converted the char pointer in odbc_get_diag_rec still refers to a stack variable instead of the new convert_string char pointer. On exit of the function odbc_get_diag_rec causes a memory exception.

I have attached the code before and after my fix. The code was downloaded from the source code link on the 19/02/2014

Charles Durrant
Thomson Reuters

Work Item Details

Original CodePlex Issue: Issue 22427 Status: Proposed Reason Closed: Unassigned Assigned to: Unassigned Reported on: Feb 24 at 10:52 AM Reported by: charliedurrant Updated on: Feb 24 at 10:52 AM Updated by: charliedurrant

Binary Attachments

patch.zip

v-mabarw avatar Jul 29 '14 22:07 v-mabarw

This issue is resolved on the latest release: Microsoft Drivers 3.1 for PHP for SQL Server

SumoLion avatar Jan 16 '15 18:01 SumoLion