Fix OBJ reader using j as both triangle counter and vertex index#1178
Fix OBJ reader using j as both triangle counter and vertex index#1178sbryngelson wants to merge 1 commit intoMFlowCode:masterfrom
Conversation
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Nitpicks 🔍
|
|
CodeAnt AI finished reviewing your PR. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug in the OBJ file reader where the variable j was incorrectly used for both tracking the triangle counter and storing the third vertex index from face definitions. This caused triangle vertex assignments to be written to incorrect array indices and could result in out-of-bounds memory access.
Changes:
- Introduced a new variable
iv3to store the third vertex index read from OBJ face lines - Updated the face parsing logic to use
iv3instead of reusingj
When reading face lines, j is overwritten by the third vertex index from the file, then used as the triangle index for model%trs(j). Introduces a separate iv3 variable for the third vertex index. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
839026a to
651c50b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1178 +/- ##
=======================================
Coverage 44.05% 44.05%
=======================================
Files 70 70
Lines 20498 20498
Branches 1990 1990
=======================================
Hits 9030 9030
Misses 10329 10329
Partials 1139 1139 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Superseded by #1240 (batched safe fixes) |
Summary
Severity: CRITICAL — triangle assignments go to wrong indices; potential OOB crash.
File:
src/common/m_model.fpp, lines 278-282In the OBJ reader,
jserves double duty as both the sequential triangle counter (initialized to 1 on line 264) and the third vertex index read from the face line. Whenread(line(3:), *) k, l, jexecutes,jis overwritten with the vertex index from the file, then immediately used as the triangle index inmodel%trs(j).Before
After
Why this went undetected
Only triggers when loading OBJ STL models, a specialized feature with limited test coverage.
Test plan
🤖 Generated with Claude Code
Fixes #1199