Merge pull request #14883 from owncloud/imagepng_expects_resource_issue

validate resource's integrity before using it
This commit is contained in:
Thomas Müller 2015-03-16 12:22:27 +01:00
commit 1075914f8a
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
*/