Skip to content

Commit

Permalink
Fix exception loading some PSD images
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-duncan committed Jun 16, 2024
1 parent 2616f71 commit b679cde
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 6 additions & 0 deletions lib/src/formats/psd/psd_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,17 @@ class PsdChannel {
if (n < 0) {
n = 1 - n;
final b = src.readByte();
if ((dstIndex + n) > dst.length) {
n = dst.length - dstIndex;
}
for (var i = 0; i < n; ++i) {
dst[dstIndex++] = b;
}
} else {
n++;
if ((dstIndex + n) > dst.length) {
n = dst.length - dstIndex;
}
for (var i = 0; i < n; ++i) {
dst[dstIndex++] = src.readByte();
}
Expand Down
4 changes: 0 additions & 4 deletions lib/src/image/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,6 @@ class Image extends Iterable<Pixel> {
Palette? palette,
ExifData? exif,
IccProfile? iccp}) {
if (numChannels < 1 || numChannels > 4) {
throw ImageException('Invalid number of channels for image $numChannels.'
' Must be between 1 and 4.');
}
iccProfile = iccp;
if (exif != null) {
_exif = ExifData.from(exif);
Expand Down
Binary file added test/_data/psd/rle_crash.psd
Binary file not shown.

0 comments on commit b679cde

Please sign in to comment.