Skip to content

Commit

Permalink
Merge pull request #14917 from owncloud/imagepng_expects_resource_iss…
Browse files Browse the repository at this point in the history
…ue_stable8

backport: validate resource's integrity before using it
  • Loading branch information
MorrisJobke committed Mar 16, 2015
2 parents 92a024b + bc5ca78 commit 35abb4d
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 35abb4d

Please sign in to comment.