Skip to content

Commit 96e9f40

Browse files
committed
Better resource guarding.
1 parent 3d7350e commit 96e9f40

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Because the linker is intended for use w
5353
[2023.09.04; Maikuolan]: Added L10N for Afrikaans and Romanian.
5454

5555
[2023.09.16~18; Maikuolan]: Significantly refactored all L10N data.
56+
57+
[2023.09.18; Maikuolan]: Better resource guarding.

src/Linker.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: PHPMailer-phpMussel linker (last modified: 2022.02.13).
11+
* This file: PHPMailer-phpMussel linker (last modified: 2023.09.18).
1212
*/
1313

1414
namespace phpMussel\PHPMailer;
@@ -81,7 +81,10 @@ public function __construct(\phpMussel\Core\Loader &$Loader)
8181

8282
$Truncate = $this->Loader->readBytes($this->Loader->Configuration['core']['truncate']);
8383
$WriteMode = (!file_exists($EventLog) || ($Truncate > 0 && filesize($EventLog) >= $Truncate)) ? 'wb' : 'ab';
84-
$Handle = fopen($EventLog, $WriteMode);
84+
if (!is_resource($Handle = fopen($EventLog, $WriteMode))) {
85+
trigger_error('The "writeToPHPMailerEventLog" event failed to open "' . $EventLog . '" for writing.');
86+
return false;
87+
}
8588
fwrite($Handle, $Data);
8689
fclose($Handle);
8790
$this->Loader->logRotation($this->Loader->Configuration['phpmailer']['event_log']);

0 commit comments

Comments
 (0)