Commit c9f0444
committed
Fix vector subscript out of range for models with partial textures
- Add bounds check in KDTreeSoup::weight() for invalid texture indices
- Add bounds checks in TexAtlas::width/height for invalid tex/level
- Add bounds checks in TexAtlas::read and TexPyramid::read
- Fix remap vector size in extractNodeTex (n_boxes instead of mesh.vert.size)
- Add defensive bounds checks throughout extractNodeTex
This fixes a crash when building Nexus files from models where not all
meshes have textures (e.g., SunglassesKhronos.glb with 5 meshes but
only 1 texture). The crash occurred on Windows Debug builds where
MSVC detects vector subscript out of range.1 parent 580c42f commit c9f0444
4 files changed
Lines changed: 37 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
368 | 371 | | |
369 | 372 | | |
370 | 373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
| 264 | + | |
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
275 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
276 | 280 | | |
277 | 281 | | |
278 | 282 | | |
| |||
288 | 292 | | |
289 | 293 | | |
290 | 294 | | |
| 295 | + | |
291 | 296 | | |
292 | 297 | | |
293 | 298 | | |
| 299 | + | |
294 | 300 | | |
295 | 301 | | |
296 | 302 | | |
| |||
358 | 364 | | |
359 | 365 | | |
360 | 366 | | |
361 | | - | |
| 367 | + | |
362 | 368 | | |
363 | 369 | | |
364 | 370 | | |
365 | 371 | | |
366 | 372 | | |
367 | 373 | | |
368 | 374 | | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
369 | 379 | | |
370 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
371 | 385 | | |
372 | 386 | | |
373 | 387 | | |
| |||
413 | 427 | | |
414 | 428 | | |
415 | 429 | | |
| 430 | + | |
416 | 431 | | |
417 | 432 | | |
418 | 433 | | |
| |||
435 | 450 | | |
436 | 451 | | |
437 | 452 | | |
| 453 | + | |
438 | 454 | | |
439 | 455 | | |
440 | 456 | | |
441 | 457 | | |
442 | | - | |
| 458 | + | |
| 459 | + | |
443 | 460 | | |
444 | 461 | | |
445 | 462 | | |
| |||
600 | 617 | | |
601 | 618 | | |
602 | 619 | | |
603 | | - | |
604 | 620 | | |
605 | 621 | | |
606 | 622 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
| |||
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
| 241 | + | |
240 | 242 | | |
241 | 243 | | |
242 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
95 | 103 | | |
96 | 104 | | |
97 | 105 | | |
| |||
0 commit comments