Open Bug 1187032 Opened 10 years ago Updated 3 years ago

Resource leak in Blit9::copy2D

Categories

(Core :: Graphics, defect)

39 Branch
defect

Tracking

()

People

(Reporter: q1, Unassigned)

References

Details

(Whiteboard: [gfx-noted])

Blit9::copy2D (gfx\angle\src\libGLESv2\renderer\d3d\d3d9\Blit9.cpp) leaks an IDirect3DSurface9 object if its call to getSurfaceLevel fails: ... 250: IDirect3DSurface9 *source = renderTarget9->getSurface(); 251: ASSERT(source); 252: 253: IDirect3DSurface9 *destSurface = NULL; 254: TextureStorage9_2D *storage9 = TextureStorage9_2D::makeTextureStorage9_2D(storage); 255: error = storage9->getSurfaceLevel(level, true, &destSurface); 256: if (error.isError()) 257: { 258: return error; 259: } 260: ASSERT(destSurface); 261: 262: gl::Error result = copy(source, sourceRect, destFormat, xoffset, yoffset, destSurface); 263: 264: SafeRelease(destSurface); 265: SafeRelease(source); 266: 267: return result; 268:} Line 250 |addref|s source, and line 265 properly |release|es it, but the |if| statement on lines 256-259 does not.
There is a similar bug in Blit9::copyCube lines 295-98 in the same module.
jgilbert, can you check this bug?
Flags: needinfo?(jgilbert)
Whiteboard: [gfx-noted]
This looks likely.
Flags: needinfo?(jgilbert)
Oh god, they're doing manual addref/release.
This is even true on top-of-tree ANGLE master.
Fortunately, this should only be a problem for us for OOMs, which are the only errors we don't catch before issuing commands to the driver.
(In reply to Jeff Gilbert [:jgilbert] from comment #6) > Fortunately, this should only be a problem for us for OOMs, which are the > only errors we don't catch before issuing commands to the driver. I guess that the only non-logic-error reason getSurfaceLevel can fail is OOM. 'Twould be nicer if this code used the RAII pattern. In a somewhat-related vein, do you know if there are any plans to use exceptions more widely in Mozilla code?
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.