Repository navigation
bugfix(mapcache): Close the file and free the buffer when a map preview copy fails - #3485
tintinhamans wants to merge 1 commit into
Conversation
3b29348 to
5a61292
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
Walkthrough
ChangesMap failure-path cleanup
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to
|
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7e468575-3b0d-4752-acb2-eca8a9b6c528
📒 Files selected for processing (1)
Core/GameEngine/Source/GameClient/MapUtil.cpp
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
5a61292 to
5a20064
Compare
| } | ||
| catch (...) | ||
| { | ||
| resetMap(); |
There was a problem hiding this comment.
🟡 Medium GameClient/MapUtil.cpp:245
A corrupt map that parses WorldInfo before failing leaves worldDict and scalar map state populated, so a later scan can attribute stale metadata such as m_nameLookupTag to another map without valid world info. resetMap() does not clear that parsed state; clear it on failure along with the other map state.
🤖 Copy this AI Prompt to have your agent fix this:
In file @Core/GameEngine/Source/GameClient/MapUtil.cpp around line 245:
A corrupt map that parses `WorldInfo` before failing leaves `worldDict` and scalar map state populated, so a later scan can attribute stale metadata such as `m_nameLookupTag` to another map without valid world info. `resetMap()` does not clear that parsed state; clear it on failure along with the other map state.
There was a problem hiding this comment.
resetMap now clears worldDict
5a20064 to
7371b20
Compare
| if (!file.parse(nullptr)) | ||
| throw ERROR_CORRUPT_FILE_FORMAT; | ||
| } | ||
| catch (...) |
There was a problem hiding this comment.
throwing and catching in the same method is imho not a very good design.
There was a problem hiding this comment.
Took the loadMap change out of this PR. That throw ends up in the engine’s uncaught exception handler anyway.
| char *buffer = nullptr; | ||
| try | ||
| { | ||
| buffer = NEW char[ fileSize ]; |
There was a problem hiding this comment.
Function returns a Bool instead of throwing now.
7371b20 to
1b06706
Compare
copyFromBigToDirextracts a map's preview image into the user folder and threw on failure. Every throw left the source file open, and the read and write failures also left the 50 to 70 KB buffer behind.getMapPreviewImageswallowed the throw and never caches the result, so the leak repeats on every preview request for that map.This bites whenever writing to the user folder fails: a Documents folder that OneDrive is syncing (#458), a read-only or full disk, or a preview locked by an antivirus scan. Each map browsed in the skirmish or LAN picker then costs a file handle and a buffer, again on every refresh.
copyFromBigToDirnow returns aBoolinstead of throwing, so the file and the buffer are released in one place on every path.