mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-81246 dml: Check the statement resource before freeing it
This commit is contained in:
parent
70f611116d
commit
388cc303f9
@ -680,9 +680,11 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
||||
* @return bool
|
||||
*/
|
||||
private function free_result($resource) {
|
||||
if (!is_bool($resource)) { // true/false resources cannot be freed
|
||||
if (!is_bool($resource) && is_resource($resource)) {
|
||||
// We need to make sure that the statement resource is in the correct type before freeing it.
|
||||
return sqlsrv_free_stmt($resource);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,7 +85,10 @@ class sqlsrv_native_moodle_recordset extends moodle_recordset {
|
||||
return false;
|
||||
}
|
||||
if (!$row = sqlsrv_fetch_array($this->rsrc, SQLSRV_FETCH_ASSOC)) {
|
||||
sqlsrv_free_stmt($this->rsrc);
|
||||
if (is_resource($this->rsrc)) {
|
||||
// We need to make sure that the statement resource is in the correct type before freeing it.
|
||||
sqlsrv_free_stmt($this->rsrc);
|
||||
}
|
||||
$this->rsrc = null;
|
||||
$this->unregister();
|
||||
return false;
|
||||
@ -133,7 +136,10 @@ class sqlsrv_native_moodle_recordset extends moodle_recordset {
|
||||
|
||||
public function close() {
|
||||
if ($this->rsrc) {
|
||||
sqlsrv_free_stmt($this->rsrc);
|
||||
if (is_resource($this->rsrc)) {
|
||||
// We need to make sure that the statement resource is in the correct type before freeing it.
|
||||
sqlsrv_free_stmt($this->rsrc);
|
||||
}
|
||||
$this->rsrc = null;
|
||||
}
|
||||
$this->current = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user