]> source.dussan.org Git - nextcloud-server.git/commitdiff
validate resource's integrity before using it
authorGeorg Ehrke <developer@georgehrke.com>
Fri, 13 Mar 2015 16:23:02 +0000 (17:23 +0100)
committerGeorg Ehrke <developer@georgehrke.com>
Mon, 16 Mar 2015 09:57:01 +0000 (10:57 +0100)
lib/private/image.php
tests/lib/image.php

index 317b6fde16058e97a4ea18dd64991c1543bfd0dd..2484aeecc63f0808749cedbd396f842accf3c114 100644 (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":
index e0009b9710ebf260f2c7de09e52f8aa6641436be..0ee517100ad58de38d0f44d7a4e86bbf07300834 100644 (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
         */