From cdccf03228065e2351d20291dae45ab1a2bf9a11 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Feb 2016 21:32:42 +0100 Subject: [PATCH] Fix mismatched delete --- components/nifosg/nifloader.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 53a0cdc19..ab6bfcff3 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1312,8 +1312,6 @@ namespace NifOsg if (pixelData->mipmaps.empty()) return NULL; - unsigned char* data = new unsigned char[pixelData->data.size()]; - memcpy(data, &pixelData->data[0], pixelData->data.size()); unsigned int width = 0; unsigned int height = 0; @@ -1326,7 +1324,6 @@ namespace NifOsg if (mipSize + mip.dataOffset > pixelData->data.size()) { std::cerr << "Internal texture's mipmap data out of bounds" << std::endl; - delete data; return NULL; } @@ -1342,10 +1339,12 @@ namespace NifOsg if (width <= 0 || height <= 0) { std::cerr << "Width and height must be non zero " << std::endl; - delete data; return NULL; } + unsigned char* data = new unsigned char[pixelData->data.size()]; + memcpy(data, &pixelData->data[0], pixelData->data.size()); + image->setImage(width, height, 1, pixelformat, pixelformat, GL_UNSIGNED_BYTE, data, osg::Image::USE_NEW_DELETE); image->setMipmapLevels(mipmapVector); image->flipVertical();