From 3459e8f4fd5d21594d3684dc432f7422f94c3e8e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 31 Oct 2017 15:55:24 +0000 Subject: [PATCH] Fixed Coverity Scan reported memory leaks --- src/osgPlugins/tga/ReaderWriterTGA.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/osgPlugins/tga/ReaderWriterTGA.cpp b/src/osgPlugins/tga/ReaderWriterTGA.cpp index b1e3ad6a4..256beb603 100644 --- a/src/osgPlugins/tga/ReaderWriterTGA.cpp +++ b/src/osgPlugins/tga/ReaderWriterTGA.cpp @@ -360,8 +360,14 @@ int *numComponents_ret) { case 1: /* colormap, uncompressed */ { - if (colormapLen == 0 || indexsize == 0) { + if (colormapLen == 0 || indexsize == 0) + { tgaerror = ERR_UNSUPPORTED; /* colormap missing or empty */ + + if (colormap) delete [] colormap; + delete [] buffer; + delete [] linebuf; + return NULL; } unsigned char * formattedMap = new unsigned char[colormapLen * format];