Skip to content

Commit 478d921

Browse files
Apply suggestions from code review
Co-authored-by: Kate <26026535+provokateurin@users.noreply.github.com> Signed-off-by: invario <67800603+invario@users.noreply.github.com>
1 parent 52ccc6e commit 478d921

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/private/Preview/Movie.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private function getSparseFile(File $file, int $size): string|false {
137137
$sparseFile = fopen($absPath, 'w');
138138

139139
// If video size is less than or equal to $size then just download entire file
140-
if (($size) >= $file->getSize()) {
140+
if ($size >= $file->getSize()) {
141141
stream_copy_to_stream($content, $sparseFile);
142142
} else {
143143
// Firsts 4 bytes indicate length of 1st atom.
@@ -185,6 +185,8 @@ private function getSparseFile(File $file, int $size): string|false {
185185
// Capping it at $size is a precaution against a corrupt/malicious 'moov' atom
186186
// Also, if the 'moov' atom size+offset extends past EOF, it is invalid.
187187
if (($moovSize === 0) || ($moovSize > $size) || ($moovOffset + $moovSize > $file->getSize())) {
188+
fclose($content);
189+
fclose($sparseFile);
188190
return false;
189191
}
190192
// Generate new file of same size
@@ -204,6 +206,7 @@ private function getSparseFile(File $file, int $size): string|false {
204206
} else {
205207
// 'ftyp' atom not found, not a valid MP4/MOV
206208
fclose($content);
209+
fclose($sparseFile);
207210
return false;
208211
}
209212
}

0 commit comments

Comments
 (0)