Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed off-by-one index check in setChildIndex #1582

Conversation

StefanHabel
Copy link
Contributor

Extended the existing test case:
valid values for index in the test case are 0 and 1 only.

Minimal repro via Python bindings:

$ python3 -c 'import MaterialX as mx; d = mx.createDocument(); b = d.addBackdrop(); d.setChildIndex(b.getName(), 1)'

Without this patch:

Segmentation fault

With this patch:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
LookupError: Invalid child index

Ran the tests locally via make && make test:

100% tests passed, 0 tests failed out of 73

Update #1581

Extended the existing test case:
valid values for `index` in the test case are `0` and `1` only.

Minimal repro via Python bindings:
```bash
$ python3 -c 'import MaterialX as mx; d = mx.createDocument(); b = d.addBackdrop(); d.setChildIndex(b.getName(), 1)'
```
Without this patch:
```bash
Segmentation fault
```
With this patch:
```python
Traceback (most recent call last):
  File "<string>", line 1, in <module>
LookupError: Invalid child index
```

Ran the tests locally via `make && make test`:
```bash
100% tests passed, 0 tests failed out of 73
```

Update AcademySoftwareFoundation#1581

Signed-off-by: Stefan Habel <19556655+StefanHabel@users.noreply.github.com>
Copy link
Member

@jstone-lucasfilm jstone-lucasfilm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, @StefanHabel, and thanks for the fix!

@jstone-lucasfilm jstone-lucasfilm changed the title Fixed an off-by-one index check in Element::setChildIndex(). Fixed off-by-one index check in setChildIndex Oct 24, 2023
@jstone-lucasfilm jstone-lucasfilm merged commit a5b832d into AcademySoftwareFoundation:main Oct 24, 2023
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants