### Godot version

 v4.0.beta11.official.91713ced8

### System information

macOS 12.6.1 Monterey, Apple M1 Pro

### Issue description

After reopening scenes with Sprite2D and trying to edit the region of the sprite again the Godot app crashed.

### Steps to reproduce

1. Open scene node_2d in the project files
2. Go to Sprite2D and click on edit region, pop up should show
3. Close the popup and close the scene with X on the tab
4. Reopen the scene, go to Sprite2D and click on Edit region
5. Godot should crash

### Minimal reproduction project

[region_crash.zip](https://github.com/godotengine/godot/files/10400566/region_crash.zip)

if (node_ninepatch || obj_styleBox.is_valid()) {
					edited_margin = -1;
					float margins[4] = { 0 };
					if (node_ninepatch) {
						margins[0] = node_ninepatch->get_patch_margin(SIDE_TOP);
						margins[1] = node_ninepatch->get_patch_margin(SIDE_BOTTOM);
						margins[2] = node_ninepatch->get_patch_margin(SIDE_LEFT);
						margins[3] = node_ninepatch->get_patch_margin(SIDE_RIGHT);
					} else if (obj_styleBox.is_valid()) {
						margins[0] = obj_styleBox->get_margin_size(SIDE_TOP);
						margins[1] = obj_styleBox->get_margin_size(SIDE_BOTTOM);
						margins[2] = obj_styleBox->get_margin_size(SIDE_LEFT);
						margins[3] = obj_styleBox->get_margin_size(SIDE_RIGHT);
					}
					Vector2 pos[4] = {
						mtx.basis_xform(rect.position + Vector2(0, margins[0])) - draw_ofs * draw_zoom,
						mtx.basis_xform(rect.position + rect.size - Vector2(0, margins[1])) - draw_ofs * draw_zoom,
						mtx.basis_xform(rect.position + Vector2(margins[2], 0)) - draw_ofs * draw_zoom,
						mtx.basis_xform(rect.position + rect.size - Vector2(margins[3], 0)) - draw_ofs * draw_zoom
					};
					if (Math::abs(mb->get_position().y - pos[0].y) < 8) {
						edited_margin = 0;
						prev_margin = margins[0];
					} else if (Math::abs(mb->get_position().y - pos[1].y) < 8) {
						edited_margin = 1;
						prev_margin = margins[1];
					} else if (Math::abs(mb->get_position().x - pos[2].x) < 8) {
						edited_margin = 2;
						prev_margin = margins[2];
					} else if (Math::abs(mb->get_position().x - pos[3].x) < 8) {