diff --git a/source/pdo_sqlsrv/pdo_dbh.cpp b/source/pdo_sqlsrv/pdo_dbh.cpp index 9f81e355..07003c84 100644 --- a/source/pdo_sqlsrv/pdo_dbh.cpp +++ b/source/pdo_sqlsrv/pdo_dbh.cpp @@ -1615,7 +1615,6 @@ zend_string * pdo_sqlsrv_dbh_last_id(_Inout_ pdo_dbh_t *dbh, _In_ const zend_str #if PHP_VERSION_ID < 80100 snprintf(buffer, LAST_INSERT_ID_QUERY_MAX_LEN, SEQUENCE_CURRENT_VALUE_QUERY, name); #else - const char *name_str = ZSTR_VAL(name); snprintf(buffer, LAST_INSERT_ID_QUERY_MAX_LEN, SEQUENCE_CURRENT_VALUE_QUERY, ZSTR_VAL(name)); #endif wsql_string = utf16_string_from_mbcs_string(SQLSRV_ENCODING_CHAR, buffer, sizeof(buffer), &wsql_len); diff --git a/source/shared/core_sqlsrv.h b/source/shared/core_sqlsrv.h index b111dee8..ef87124d 100644 --- a/source/shared/core_sqlsrv.h +++ b/source/shared/core_sqlsrv.h @@ -374,6 +374,10 @@ inline void sqlsrv_free_trace( _Inout_ void* ptr, _In_ const char* file, _In_ in #else +// Unlike their C standard library's counterparts the Zend Engine's memory management functions +// emalloc or erealloc won't return NULL in case of an problem while allocating the requested +// memory but bail out and terminate the current request. +// Check www.phpinternalsbook.com/php7/memory_management/zend_memory_manager.html for details inline void* sqlsrv_malloc( _In_ size_t size ) { return emalloc( size ); diff --git a/source/shared/core_stmt.cpp b/source/shared/core_stmt.cpp index 29511a82..92c7cfc7 100644 --- a/source/shared/core_stmt.cpp +++ b/source/shared/core_stmt.cpp @@ -3673,7 +3673,7 @@ bool sqlsrv_params_container::send_next_packet(_Inout_ sqlsrv_stmt* stmt) } // The helper method send_stream_packet() returns false when EOF is reached - if (current_param->send_data_packet(stmt) == false) { + if (current_param && current_param->send_data_packet(stmt) == false) { // Now that EOF has been reached, reset current_param for next round // Bear in mind that SQLParamData might request the same stream resource again current_param = NULL;