Skip to content

Runtime error when trying to select invalid ROIs #57

Description

@s1hofmann

Version
1.0.0

Short overview
Selecting invalid regions of an image (e.g. bigger than the actual image) causes uncaught runtime errors

Detailed error description
When providing a ROI which exceeds an images size, nut.js does no checks to prevent invalid memory access.
This leads to uncaught std::runtime_errors

Steps to reproduce error

describe("Invalid ROI test", () => {
  it("should trigger a runtime error", async () => {
    // GIVEN
    const SUT = new TemplateMatchingFinder();
    const imagePath = path.resolve(__dirname, "./__mocks__/save_as.png");
    const minConfidence = 0.99;
    const vision = new ScreenAction();
    const haystack = await vision.grabScreen();
    const matchRequest = new MatchRequest(
      haystack,
      imagePath,
      new Region(0, 0, haystack.width, haystack.height),
      minConfidence
    );

    // WHEN
    await SUT.findMatch(matchRequest, true);

    // THEN
    // libc++abi.dylib: terminating with uncaught exception of type std::runtime_error
  });
});

Additional content

Please provide any (mandatory) additional data to reproduce the error (Dockerfiles etc.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions