check if file exists before calling unlink (#327)

* check if file exists before calling unlink

file_exists has a known vulnerability.
Replacing with the internal one.

Co-authored-by: Nicola Asuni <nicolaasuni@users.noreply.github.com>
This commit is contained in:
mtreuberg 2021-03-27 10:08:05 +01:00 committed by GitHub
parent 14fd6779f3
commit 978eb8c824
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7806,7 +7806,7 @@ class TCPDF {
}
if (isset($this->imagekeys)) {
foreach($this->imagekeys as $file) {
if (strpos($file, K_PATH_CACHE) === 0) {
if (strpos($file, K_PATH_CACHE) === 0 && TCPDF_STATIC::file_exists($file)) {
@unlink($file);
}
}