Skip to content
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
6 changes: 3 additions & 3 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
strategy:
matrix:
bits: [32, 64]
os: [windows-2019, windows-2022]
os: [windows-2022, windows-2025]
include:
- bits: 32
arch: x86
Expand Down Expand Up @@ -270,7 +270,7 @@ jobs:
needs: windows-mingw-build
strategy:
matrix:
os: [windows-2019, windows-2022]
os: [windows-2022, windows-2025]
bits: [32, 64]
fail-fast: false
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -331,7 +331,7 @@ jobs:
- bits: 64
arch: x86_64
fail-fast: false
runs-on: windows-2019
runs-on: windows-2022
timeout-minutes: 30
steps:
- name: Checkout repo
Expand Down
2 changes: 2 additions & 0 deletions include/gfx/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ struct Options {
uint16_t top;
uint16_t width;
uint16_t height;
uint32_t right() const { return left + width * 8; }
uint32_t bottom() const { return top + height * 8; }
} inputSlice{0, 0, 0, 0}; // -L (margins in clockwise order, like CSS)
std::array<uint16_t, 2> maxNbTiles{UINT16_MAX, 0}; // -N
uint16_t nbPalettes = 8; // -n
Expand Down
2 changes: 1 addition & 1 deletion src/gfx/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ int main(int argc, char *argv[]) {
}
fprintf(
stderr,
"\tInput image slice: %" PRIu32 "x%" PRIu32 " pixels starting at (%" PRId32 ", %" PRId32
"\tInput image slice: %" PRIu16 "x%" PRIu16 " pixels starting at (%" PRIu16 ", %" PRIu16
")\n",
options.inputSlice.width,
options.inputSlice.height,
Expand Down
24 changes: 24 additions & 0 deletions src/gfx/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,30 @@ class Png {
if (options.inputSlice.height == 0 && height % 8 != 0) {
fatal("Image height (%" PRIu32 " pixels) is not a multiple of 8!", height);
}
if (options.inputSlice.right() > width || options.inputSlice.bottom() > height) {
error(
"Image slice ((%" PRIu16 ", %" PRIu16 ") to (%" PRIu32 ", %" PRIu32
")) is outside the image bounds (%" PRIu32 "x%" PRIu32 ")!",
options.inputSlice.left,
options.inputSlice.top,
options.inputSlice.right(),
options.inputSlice.bottom(),
width,
height
);
if (options.inputSlice.width % 8 == 0 && options.inputSlice.height % 8 == 0) {
fprintf(
stderr,
"note: Did you mean the slice \"%" PRIu32 ",%" PRIu32 ":%" PRId32 ",%" PRId32
"\"? (width and height are in tiles, not pixels!)\n",
options.inputSlice.left,
options.inputSlice.top,
options.inputSlice.width / 8,
options.inputSlice.height / 8
);
}
giveUp();
}

pixels.resize(static_cast<size_t>(width) * static_cast<size_t>(height));

Expand Down
3 changes: 3 additions & 0 deletions test/gfx/bad_slice.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
error: Image slice ((2, 2) to (130, 130)) is outside the image bounds (20x20)!
note: Did you mean the slice "2,2:2,2"? (width and height are in tiles, not pixels!)
Conversion aborted after 1 error
1 change: 1 addition & 0 deletions test/gfx/bad_slice.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-L 2,2:16,16
Binary file added test/gfx/bad_slice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions test/gfx/oob_slice_wh.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: Image slice ((2, 2) to (34, 18)) is outside the image bounds (20x20)!
Conversion aborted after 1 error
1 change: 1 addition & 0 deletions test/gfx/oob_slice_wh.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-L 2,2:4,2
Binary file added test/gfx/oob_slice_wh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions test/gfx/oob_slice_xy.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: Image slice ((2, 99) to (10, 107)) is outside the image bounds (20x20)!
Conversion aborted after 1 error
1 change: 1 addition & 0 deletions test/gfx/oob_slice_xy.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-L 2,99:1,1
Binary file added test/gfx/oob_slice_xy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading