validate resource's integrity before using it
This commit is contained in:
parent
0d9f149dd9
commit
09b05373ed
|
@ -283,9 +283,12 @@ class OC_Image {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string Returns the raw image data.
|
||||
* @return null|string Returns the raw image data.
|
||||
*/
|
||||
function data() {
|
||||
if (!$this->valid()) {
|
||||
return null;
|
||||
}
|
||||
ob_start();
|
||||
switch ($this->mimeType) {
|
||||
case "image/png":
|
||||
|
|
|
@ -144,6 +144,11 @@ class Test_Image extends \Test\TestCase {
|
|||
$this->assertEquals($expected, $img->data());
|
||||
}
|
||||
|
||||
public function testDataNoResource() {
|
||||
$img = new \OC_Image();
|
||||
$this->assertNull($img->data());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testData
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue