Examples of errors detected by the V586 diagnostic.


V586. The 'Foo' function is called twice for deallocation of the same resource.


Blender

V586 The 'clear' function is called twice for deallocation of the same resource. Check lines: 176, 177. bf_intern_elbeem ntl_geometrymodel.cpp 177


int ntlGeometryObjModel::initModel(....)
{
  ...
  ntlSetVec3f averts; averts.mVerts.clear();
  ntlSetVec3f anorms; averts.mVerts.clear();
  ...
}

This is what should have been written here: ntlSetVec3f averts; averts.mVerts.clear(); ntlSetVec3f anorms; anorms.mVerts.clear();


OpenMW

V586 The 'clear' function is called twice for deallocation of the same resource. Check lines: 48, 49. components loadclot.cpp 49


void Clothing::blank()
{
  mData.mType = 0;
  mData.mWeight = 0;
  mData.mValue = 0;
  mData.mEnchant = 0;
  mParts.mParts.clear();
  mName.clear();
  mModel.clear();
  mIcon.clear();
  mIcon.clear();
  mEnchant.clear();
  mScript.clear();
}

VNL

V586 The 'clear' function is called twice for deallocation of the same resource. Check lines: 202, 203. testlib_main.cxx 203


void testlib_register_test(const vcl_string & name,
                           TestMainFunction func)
{
  testlib_test_func_.push_back(func);
  testlib_test_name_.push_back(name);
}

void testlib_cleanup()
{
  testlib_test_func_.clear();
  testlib_test_func_.clear();
}

Miranda NG

V586 The 'DeleteObject' function is called twice for deallocation of the same resource. Check lines: 264, 273. UInfoEx svc_flagsicons.cpp 273


static INT_PTR ServiceCreateMergedFlagIcon(....)
{
  HRGN hrgn;
  ....
  if (hrgn!=NULL) {
    SelectClipRgn(hdc,hrgn);
    DeleteObject(hrgn);
    ....
    DeleteObject(hrgn);
  }
  ....
}

OpenMW

V586 The 'clear' function is called twice for deallocation of the same resource. Check lines: 110, 117. loadregn.cpp 117


std::string mId, mName, mSleepList;

void Region::blank()
{
  mName.clear();

  mData.mClear = mData.mCloudy = mData.mFoggy = mData.mOvercast =
    mData.mRain = mData.mThunder = mData.mAsh,
    mData.mBlight = mData.mA = mData.mB = 0;

  mMapColor = 0;

  mName.clear();
  mSleepList.clear();
  mSoundList.clear();
}

mName string is cleared two times. Apparently mId string should be cleared in one place.


Blender

V586 The 'clear' function is called twice for deallocation of the same resource. Check lines: 149, 156. tile.cpp 156


int TileManager::gen_tiles(bool sliced)
{
  ....
  state.tiles.clear();         //<=
  ....
  int tile_index = 0;

  state.tiles.clear();
  state.tiles.resize(num);
  ....
}


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++, and C#

goto PVS-Studio;
We use cookies for the analysis of events to improve our content and make user interaction more convenient. By continuing the view of our web-pages you accept the terms of using these files. You can find out more about cookie-files and privacy policy or close the notification, by clicking on the button. Learn More →
Do not show