Examples of errors detected by the V611 diagnostic.

V611. The memory allocation and deallocation methods are incompatible.


OpenCV

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] linearwt;'. hog.cpp 2630


void HOGDescriptor::detectMultiScaleROI(....) const
{
  ....
  double *linearwt = new double[totwords+1];
  ....
  delete linearwt;
  ....
}

Skia Graphics Engine

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] utf8;'. skobjectparser.cpp 346


SkString* SkObjectParser::TextToString(....)
{
  ....
  char* utf8 = new char[sizeNeeded];
  SkUTF16_ToUTF8((uint16_t*)text, byteLength / 2, utf8);
  decodedText->append(utf8, sizeNeeded);
  delete utf8;
  ....
}

Multi Theft Auto

V611 The memory was allocated using 'new' operator but was released using the 'free' function. Consider inspecting operation logics behind the 'buf' variable. cresourcechecker.cpp 921


int CResourceChecker::ReplaceFilesInZIP(....)
{
  ....
  // Load file into a buffer
  buf = new char[ ulLength ];
  if ( fread ( buf, 1, ulLength, pFile ) != ulLength )
  {
    free( buf );
    buf = NULL;
  }
  ....
}

Trans-Proteomic Pipeline

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] pepString;'. pepxfield.cxx 1023


string
Field::getText(....)
{
  ....
  char* pepString = new char[peplen + 1];
  ....
  delete pepString;
  ....
}

Identical errors can be found in some other places:

  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] next;'. cruxdiscrimvalmixturedistr.cxx 705
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] next;'. cruxdiscrimvalmixturedistr.cxx 715
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] newsettings;'. mascotdiscrimvalmixturedistr.cxx 426
  • And 7 additional diagnostic messages.

TinyCAD

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] Np;'. context.cpp 446


void CContext::PolyBezier(CDPoint *pts, int Size)
{
  // Make a new array to hold the points
  POINT *Np = new POINT[Size];
  ....
  delete Np;
}

Identical errors can be found in some other places:

  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] pLogPal;'. imagepng.cpp 213
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] buf;'. streamdb.cpp 182

OpenCOLLADA

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] buffer;'. colladamayadocumentexporter.cpp 345


String DocumentExporter::mayaNameToColladaName (....)
{
  ....
  char* buffer = new char[length+1];
  ....
  delete buffer;
  ....
}

Apache Xerces Project

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] objLoc;'. psviwriterhandlers.cpp 1631


const XMLCh* PSVIWriterHandlers::getIdName(XSObject* obj) {
  XMLCh* objLoc = new XMLCh[9];
  ....
  delete objLoc;
}

Snes9x

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] tmp;'. netplay.cpp 389


bool8 S9xNPConnect ()
{
  ....
  uint8 *tmp = new uint8 [len];
  ....
  delete tmp;
  ....
}

Identical errors can be found in some other places:

  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] data;'. netplay.cpp 423
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] data;'. netplay.cpp 433
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] data;'. netplay.cpp 445
  • And 10 additional diagnostic messages.

CxImage

V611 The memory was allocated using 'new' operator but was released using the 'free' function. Consider inspecting operation logics behind the 'ptmp' variable. ximalyr.cpp 50


bool CxImage::LayerCreate(int32_t position)
{
  ....
  CxImage** ptmp = new CxImage*[info.nNumLayers + 1];
  ....
  } else {
    free(ptmp);
    return false;
  }
  ....
}

Miranda IM

V611 The memory was allocated using 'new' operator but was released using the 'free' function. Consider inspecting operation logics behind the 'recentEntries' variable. trayicon.cpp 355


void TSAPI LoadFavoritesAndRecent()
{
  ....
  recentEntries = new RCENTRY[nen_options.wMaxRecent + 1];
  if (recentEntries != NULL) {
    ....
    if (iIndex == 0) {
      free(recentEntries);
      return;
    }
  ....
}

Unreal Engine 4

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] VersionInfo;'. windowsplatformexceptionhandling.cpp 107


static void GetModuleVersion( .... )
{
  ....
  char* VersionInfo = new char[InfoSize];
  ....
  delete VersionInfo;
  ....
}

libstagefright

V611 The memory was allocated using 'new' operator but was released using the 'free' function. Consider inspecting operation logics behind the 'buffer' variable. astring.cpp 340


AString StringPrintf(const char *format, ...) {
  va_list ap;
  va_start(ap, format);

  char *buffer;
#ifdef _MSC_VER
  int n = vsnprintf(NULL, 0, format, ap);
  buffer = new char[n+1];                    // <=
  vsnprintf(buffer, n+1, format, ap);
#else
  vasprintf(&buffer, format, ap);
#endif
  va_end(ap);

  AString result(buffer);

  free(buffer);                              // <=
  buffer = NULL;

  return result;
}

Mozilla Firefox

V611 The memory was allocated using 'new' operator but was released using the 'free' function. Consider inspecting operation logics behind the 'instanceData' variable. nptest.cpp 1029


NPError
NPP_New(....)
{
  ....
  InstanceData* instanceData = new InstanceData;
  ....
  NPError err = pluginInstanceInit(instanceData);
  if (err != NPERR_NO_ERROR) {
    NPN_ReleaseObject(scriptableObject);
    free(instanceData);
    return err;
  }
  ....
}

Newton Game Dynamics

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] boneWeightIndex;'. dgeometrynodeskinmodifierinfo.cpp 97

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] vertexWeights;'. dgeometrynodeskinmodifierinfo.cpp 98


void dGeometryNodeSkinModifierInfo::RemoveUnusedVertices(
  const int* const vertexMap)
{
  ....
  dVector* vertexWeights = new dVector[m_vertexCount];
  dBoneWeightIndex* boneWeightIndex =
                           new dBoneWeightIndex[m_vertexCount];
  ....
  delete boneWeightIndex;
  delete vertexWeights;
}

Identical errors can be found in some other places:

  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] uv1VertexIndex;'. dscenestdafx.cpp 639
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] uv0VertexIndex;'. dscenestdafx.cpp 640
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] normalVertexIndex;'. dscenestdafx.cpp 641
  • And 7 additional diagnostic messages.

Oracle VM Virtual Box

V611 The memory was allocated using 'malloc/realloc' function but was released using the 'delete' operator. Consider inspecting operation logics behind the 'pBuffer' variable. tsmfhook.cpp 1261


void
ReadTSMF(uint32_t u32ChannelHandle,
         uint32_t u32HGCMClientId,
         uint32_t u32SizeAvailable)
{
  ....
  PBYTE pBuffer = (PBYTE)malloc(u32SizeAvailable + sizeof(....));
  ....
  delete [] pBuffer;
  ....
}

Miranda NG

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] workingDir;'. IEView ieview_main.cpp 68


extern "C" int __declspec(dllexport) Load(void)
{
  int wdsize = GetCurrentDirectory(0, NULL);
  TCHAR *workingDir = new TCHAR[wdsize];
  GetCurrentDirectory(wdsize, workingDir);
  Utils::convertPath(workingDir);
  workingDirUtf8 = mir_utf8encodeT(workingDir);
  delete workingDir;
  ....
}

Identical errors can be found in some other places:

  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] tTemp;'. IEView ieview.cpp 935
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] answer;'. MirOTR dialogs.cpp 268
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] question;'. MirOTR dialogs.cpp 418
  • And 17 additional diagnostic messages.

Miranda NG

V611 The memory was allocated using 'new' operator but was released using the 'free' function. Consider inspecting operation logics behind the 'piWidths' variable. MirandaG15 clcdlabel.cpp 209


void CLCDLabel::UpdateCutOffIndex()
{
  ....
  int *piWidths = new int[(*--m_vLines.end()).length()];
  ....
  free(piWidths);
  ....
}

Identical errors can be found in some other places:

  • V611 The memory was allocated using 'malloc/realloc' function but was released using the 'delete' operator. Consider inspecting operation logics behind the 'ptab' variable. Xfire tools.cpp 386
  • V611 The memory was allocated using 'malloc/realloc' function but was released using the 'delete' operator. Consider inspecting operation logics behind the 'ptab' variable. Xfire tools.cpp 595
  • V611 The memory was allocated using 'new' operator but was released using the 'free' function. Consider inspecting operation logics behind the 'str1' variable. YAMN mailbrowser.cpp 1427
  • And 8 additional diagnostic messages.

LibreOffice

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] pStrings;'. profile.hxx 103


sal_uInt32 readIdent(....)
{
  size_t nItems = rStrings.size();
  const sal_Char** pStrings = new const sal_Char*[ nItems+1 ];
  ....
  delete pStrings;
  return nRet;
}

Identical errors can be found in some other places:

  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] pStrings;'. profile.hxx 134

Unreal Engine 4

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] Code;'. openglshaders.cpp 1790


template<class TOpenGLStage>
static FString GetShaderStageSource(TOpenGLStage* Shader)
{
  ....
  if(Len > 0)
  {
    ANSICHAR* Code = new ANSICHAR[Len + 1];                 // <=
    glGetShaderSource(Shaders[i], Len + 1, &Len, Code);
    Source += Code;
    delete Code;                                            // <=
  }
  ....
}

Unreal Engine 4

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] CompressedDataRaw;'. crashupload.cpp 222


void FCrashUpload::CompressAndSendData()
{
  ....
  uint8* CompressedDataRaw = new uint8[BufferSize];         // <=

  int32 CompressedSize = BufferSize;
  int32 UncompressedSize = UncompressedData.Num();
  ....
  // Copy compressed data into the array.
  TArray<uint8> CompressedData;
  CompressedData.Append( CompressedDataRaw, CompressedSize );
  delete CompressedDataRaw;                                 // <=
  CompressedDataRaw = nullptr;
  ....
}

Mozilla Thunderbird

V611 The memory was allocated using 'new' operator but was released using the 'free' function. Consider inspecting operation logics behind the 'instanceData' variable. nptest.cpp 971


NPError NPP_New(....)
{
  ....
  InstanceData* instanceData = new InstanceData;
  ....
  free(instanceData);
  ....
}

Unreal Engine 4

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] Buffer;'. bootstrappackagedgame.cpp 110


int SpawnTarget(WCHAR* CmdLine)
{
  ....
  if(!CreateProcess(....))
  {
    DWORD ErrorCode = GetLastError();

    WCHAR* Buffer = new WCHAR[wcslen(CmdLine) + 50];
    wsprintf(Buffer,
      L"Couldn't start:\n%s\nCreateProcess() returned %x.",
      CmdLine, ErrorCode);
    MessageBoxW(NULL, Buffer, NULL, MB_OK);
    delete Buffer;

    return 9005;
  }
  ....
}

Identical errors can be found in some other places:

  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] ChildCmdLine;'. bootstrappackagedgame.cpp 157
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] ChildCmdLine;'. bootstrappackagedgame.cpp 165
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] ChildCmdLine;'. bootstrappackagedgame.cpp 169

Dolphin Smalltalk 7

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] msg;'. compiler.cpp 379


Compiler::StaticType Compiler::FindNameAsStatic(....)
{
  ....
  char* msg = new char[strlen(szPrompt)+name.size()+32];
  ::wsprintf(msg, szPrompt, name.c_str());
  char szCaption[256];
  ::LoadString(GetResLibHandle(), IDR_COMPILER, szCaption, ....);
  int answer = ::MessageBox(NULL, msg, szCaption, ....);
  delete msg;
  ....
}

OpenToonz

V611 The memory was allocated using 'new' operator but was released using the 'free' function. Consider inspecting operation logics behind the 'row' variable. motionblurfx.cpp 288


template <class T>
void doDirectionalBlur(....)
{
  T *row, *buffer;
  ....
  row = new T[lx + 2 * brad + 2]; // <=
  if (!row)
    return;
  memset(row, 0, (lx + 2 * brad + 2) * sizeof(T));
  ....
  free(row);                      // <=
  r->unlock();
}

OpenToonz

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] uPrime;'. tstroke.cpp 3353


double *reparameterize3D(....)
{
  double *uPrime = new double[size]; // <=

  for (int i = 0; i < size; i++) {
    uPrime[i] = NewtonRaphsonRootFind3D(....);
    if (!_finite(uPrime[i])) {
      delete uPrime;                 // <=
      return 0;
    }
  }
  ....
}

Identical errors can be found in some other places:

  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] plt;'. pli_io.cpp 1054
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] plt;'. pli_io.cpp 1077
  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] objectOffset;'. pli_io.cpp 2070
  • And 17 additional diagnostic messages.

Scilab

V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] piP;'. sci_grand.cpp 990


types::Function::ReturnValue sci_grand(....)
{
  ....
  int* piP = new int[vectpDblInput[0]->getSize()];
  int* piOut = new int[pDblOut->getSize()];
  ....
  delete piP;
  delete piOut;
  ....
}

Identical errors can be found in some other places:

  • V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] piOut;'. sci_grand.cpp 991


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;