Conversation
Greptile SummaryThis PR successfully fixes an integer overflow bug in LGO model file name computation by casting Changes:
Overflow resolution: Confidence Score: 5/5
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["import_gltf_with_char_id / import_gltf_with_char_id_detailed\nmodel_id: u32"] --> B["Iterate mesh_idx in 0..mesh_count"]
B --> OLD["OLD: model_id * 1000000 + mesh_idx as u32\nu32 arithmetic"]
OLD -->|"model_id < 4295"| OK1["Correct u32 result\ne.g. 725000000"]
OLD -->|"model_id >= 4295"| ERR["u32 OVERFLOW\npanic in debug or wrap in release"]
B --> NEW["NEW: cast model_id to u64 first\nu64 arithmetic"]
NEW --> SAFE["Correct u64 result, no overflow"]
SAFE --> RESULT["Reliable filename computation\ne.g. 0725000000.lgo"]
RESULT --> WRITE["File::create ./imports/character/model/filename"]
Last reviewed commit: 264b0a5 |
Additional Comments (3)
|
If the character model name is longer than 2147, there will be problems when generating the model file name.
For example, 2148 is converted to 2148000000, which is greater than the maximum int value.