Skip to content

bugfix(w3d): Fix leaked surface copy in screenshot and movie capture - #636

Open
tintinhamans wants to merge 1 commit into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/fix/screenshot-surface-leak
Open

tintinhamans wants to merge 1 commit into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/fix/screenshot-surface-leak

Conversation

@tintinhamans

@tintinhamans tintinhamans commented Oct 11, 2026 •

Copy link
Copy Markdown

_Create_DX8_Surface returns a surface that already holds one reference. W3D_TakeCompressedScreenshot wraps it with the SurfaceClass(IDirect3DSurface8*) constructor, which goes through Attach and takes a second one. ~SurfaceClass releases one, so every screenshot leaks a back buffer sized image surface.

The copy is now built with SurfaceClass(width, height, format), which owns the only reference. Same image surface, same blit, same lock. The probe capture in OnlineServices_Init.cpp already releases its raw surface and is not affected.

This is the merged upstream TheSuperHackers#3477, cherry-picked as is. It also fixes the same leak in WW3D::Make_Screen_Shot and WW3D::Update_Movie_Capture (ww3d.cpp, both Generals and GeneralsMD), which the earlier version of this PR did not touch, and updates the copyright years in W3DScreenshot and stb_image_write_impl.cpp.

@tintinhamans
tintinhamans force-pushed the arctic/go/fix/screenshot-surface-leak branch from f0f5c52 to c102097 Compare October 15, 2026 22:28
@tintinhamans tintinhamans changed the title bugfix(w3d): Fix leaked surface copy in screenshot capture bugfix(w3d): Fix leaked surface copy in screenshot and movie capture Oct 15, 2026
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.

1 participant