validate resource's integrity before using it

This commit is contained in:
Georg Ehrke 2015-03-13 17:23:02 +01:00
parent 0d9f149dd9
commit 09b05373ed
2 changed files with 9 additions and 1 deletions

View File

@ -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":

View File

@ -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
*/