File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments