Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/PelIfd.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,13 @@ public function load(PelDataWindow $d, $offset)
}

if ($starting_offset != $o) {
$this->sub[$type] = new PelIfd($type);
$this->sub[$type]->load($d, $o);
$ifd = new PelIfd($type);
try {
$ifd->load($d, $o);
$this->sub[$type] = $ifd;
} catch (PelDataWindowOffsetException $e) {
Pel::maybeThrow(new PelIfdException($e->getMessage()));
}
} else {
Pel::maybeThrow(new PelIfdException('Bogus offset to next IFD: %d, same as offset being loaded from.', $o));
}
Expand Down Expand Up @@ -760,7 +765,11 @@ private function safeSetThumbnail(PelDataWindow $d, $offset, $length)
}

/* Now set the thumbnail normally. */
$this->setThumbnail($d->getClone($offset, $length));
try {
$this->setThumbnail($d->getClone($offset, $length));
} catch (PelDataWindowWindowException $e) {
Pel::maybeThrow(new PelIfdException($e->getMessage()));
}
}
}

Expand Down
17 changes: 13 additions & 4 deletions test/Bug2979466Test.php → test/BrokenImagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,20 @@
use lsolesen\pel\PelJpeg;
use PHPUnit\Framework\TestCase;

class Bug2979466Test extends TestCase
class BrokenImagesTest extends TestCase
{
function testParsingNotFailingOnRecursingIfd()
public function testWindowWindowExceptionIsCaught()
{
$file = dirname(__FILE__) . '/images/bug2979466.jpg';
$jpeg = new PelJpeg($file);
new PelJpeg(dirname(__FILE__) . '/broken_images/gh-10-a.jpg');
}

public function testWindowOffsetExceptionIsCaught()
{
new PelJpeg(dirname(__FILE__) . '/broken_images/gh-10-b.jpg');
}

public function testParsingNotFailingOnRecursingIfd()
{
new PelJpeg(dirname(__FILE__) . '/broken_images/gh-11.jpg');
}
}
51 changes: 0 additions & 51 deletions test/Bug1730993Test.php

This file was deleted.

Binary file added test/broken_images/gh-10-b.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed test/images/bug1730993_tmp.jpg
Binary file not shown.