Skip to content

Commit

Permalink
Merge pull request #14883 from owncloud/imagepng_expects_resource_issue
Browse files Browse the repository at this point in the history
validate resource's integrity before using it
  • Loading branch information
DeepDiver1975 committed Mar 16, 2015
2 parents 997a7a2 + 09b0537 commit 1075914
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/private/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,12 @@ public function resource() {
}

/**
* @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":
Expand Down
5 changes: 5 additions & 0 deletions tests/lib/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ public function testData() {
$this->assertEquals($expected, $img->data());
}

public function testDataNoResource() {
$img = new \OC_Image();
$this->assertNull($img->data());
}

/**
* @depends testData
*/
Expand Down

0 comments on commit 1075914

Please sign in to comment.