Skip to content
This repository was archived by the owner on May 26, 2022. It is now read-only.

Commit e9cd7a3

Browse files
committed
Merge pull request #199 from box/check_valid_resource_on_close
Check file handle is valid before manipulating it
2 parents 71a6f6a + 8bb42eb commit e9cd7a3

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/Spout/Writer/ODS/Internal/Worksheet.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ protected function getCellContent($cellValue, $styleIndex, $numTimesValueRepeate
218218
*/
219219
public function close()
220220
{
221+
if (!is_resource($this->sheetFilePointer)) {
222+
return;
223+
}
224+
221225
fclose($this->sheetFilePointer);
222226
}
223227
}

src/Spout/Writer/XLSX/Helper/SharedStringsHelper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ public function writeString($string)
8888
*/
8989
public function close()
9090
{
91+
if (!is_resource($this->sharedStringsFilePointer)) {
92+
return;
93+
}
94+
9195
fwrite($this->sharedStringsFilePointer, '</sst>');
9296

9397
// Replace the default strings count with the actual number of shared strings in the file header

src/Spout/Writer/XLSX/Internal/Worksheet.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ public function addRow($dataRow, $style)
178178
*/
179179
public function close()
180180
{
181+
if (!is_resource($this->sheetFilePointer)) {
182+
return;
183+
}
184+
181185
fwrite($this->sheetFilePointer, '</sheetData>');
182186
fwrite($this->sheetFilePointer, '</worksheet>');
183187
fclose($this->sheetFilePointer);

0 commit comments

Comments
 (0)