mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-19 15:35:52 +00:00
PluginBase: fixed resource leak
all this time we've been harping at plugin devs to fix their own leaks, and here's one right under our noses that no one spotted for 10 years ... this leak is rather common, since it will occur whenever a plugin attempts to save a resource which already exists in the data folder. This bug was introduced in 2014 by commit 63288346814b7b827f1f7cc7a16419af43bd0bfa.
This commit is contained in:
parent
d88c3d8ced
commit
b4c5f5d58d
@ -226,19 +226,19 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
return false;
|
||||
}
|
||||
|
||||
$out = Path::join($this->dataFolder, $filename);
|
||||
if(file_exists($out) && !$replace){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(($resource = $this->getResource($filename)) === null){
|
||||
return false;
|
||||
}
|
||||
|
||||
$out = Path::join($this->dataFolder, $filename);
|
||||
if(!file_exists(dirname($out))){
|
||||
mkdir(dirname($out), 0755, true);
|
||||
}
|
||||
|
||||
if(file_exists($out) && !$replace){
|
||||
return false;
|
||||
}
|
||||
|
||||
$fp = fopen($out, "wb");
|
||||
if($fp === false) throw new AssumptionFailedError("fopen() should not fail with wb flags");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user