Примеры ошибок, обнаруженных с помощью диагностики V1053
V1053. Calling the 'foo' virtual function in the constructor/destructor may lead to unexpected result at runtime.
qdEngine
V1053 [CERT-OOP50-CPP] Calling the 'Finit' virtual function in the destructor may lead to unexpected result at runtime. gr_dispatcher.cpp 54
class grDispatcher
{
....
virtual ~grDispatcher();
virtual bool Finit();
....
};
grDispatcher::~grDispatcher()
{
Finit();
if(dispatcher_ptr_ == this) dispatcher_ptr_ = 0;
}
bool grDispatcher::Finit()
{
#ifdef _GR_ENABLE_ZBUFFER
free_zbuffer();
#endif
flags &= ~GR_INITED;
SizeX = SizeY = 0;
wndPosX = wndPosY = 0;
screenBuf = NULL;
delete yTable;
yTable = NULL;
return true;
}
class DDraw_grDispatcher : public grDispatcher
{
....
~DDraw_grDispatcher();
bool Finit();
....
};
DDraw_grDispatcher::~DDraw_grDispatcher()
{
if(ddobj_){
ddobj_ -> Release();
ddobj_ = NULL;
}
video_modes_.clear();
}
bool DDraw_grDispatcher::Finit()
{
grDispatcher::Finit();
if(back_surface_){
....
ddobj_ -> SetCooperativeLevel((HWND)Get_hWnd(),DDSCL_NORMAL);
if(fullscreen_ && ddobj_) ddobj_ -> RestoreDisplayMode();
}
if(prim_surface_){
prim_surface_ -> Release();
prim_surface_ = NULL;
}
if(back_surface_){
back_surface_ -> Release();
back_surface_ = NULL;
}
return true;
}
Xenia
V1053 Calling the 'Reset' virtual function in the destructor may lead to unexpected result at runtime. assembler.cc 18
class Assembler
{
public:
explicit Assembler(Backend* backend);
virtual ~Assembler();
virtual bool Initialize();
virtual void Reset();
....
}
Assembler::~Assembler() { Reset(); }
class X64Assembler : public Assembler
{
public:
explicit X64Assembler(X64Backend* backend);
~X64Assembler() override;
bool Initialize() override;
void Reset() override;
....
}