C28105
Note
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
Warning C28105: Leaking resource due to an exception
The specified resource is not freed when an exception is raised. The statement specified by the path can raise an exception. This warning is similar to warning C28103, except that in this case an exception is involved.
Example
The following code example generates this warning:
res = KeSaveFloatingPointState(buffer);
res = AllocateResource(Resource);
char *p2 = new char[10]; // could throw
delete[] p2;
FreeResource(Resource)
The following code example avoids this warning:
res = AllocateResource(Resource);
char *p2;
try {
p2 = new char[10];
} catch (std::bad_alloc *e) {
// just handle the throw
;
}
FreeResource(Resource)