diff --git a/libraries/gpu/src/gpu/Resource.cpp b/libraries/gpu/src/gpu/Resource.cpp index f1956727f8..a13a5cc444 100644 --- a/libraries/gpu/src/gpu/Resource.cpp +++ b/libraries/gpu/src/gpu/Resource.cpp @@ -27,9 +27,9 @@ Resource::Size Resource::Sysmem::allocateMemory(Byte** dataAllocated, Size size) if (size > 0) { // Try allocating as much as the required size + one block of memory newSize = size; - (*dataAllocated) = new Byte[newSize]; - // Failed? - if (!(*dataAllocated)) { + try { + (*dataAllocated) = new Byte[newSize]; + } catch (const std::bad_alloc&) { qWarning() << "Buffer::Sysmem::allocate() : Can't allocate a system memory buffer of " << newSize << "bytes. Fails to create the buffer Sysmem."; return NOT_ALLOCATED; } diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index f4121d051f..b1e92e2140 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -1024,7 +1024,7 @@ int Octree::encodeTreeBitstream(OctreeElement* element, roomForOctalCode = packetData->startSubTree(newCode); if (newCode) { - delete newCode; + delete[] newCode; codeLength = numberOfThreeBitSectionsInCode(newCode); } else { codeLength = 1; @@ -2064,7 +2064,7 @@ bool Octree::readJSONFromStream(unsigned long streamLength, QDataStream& inputSt QVariant asVariant = asDocument.toVariant(); QVariantMap asMap = asVariant.toMap(); readFromMap(asMap); - delete rawData; + delete[] rawData; return true; }