From ec836d970f77f6adff02d6ad330839141a4e2fa4 Mon Sep 17 00:00:00 2001 From: Dhruv Khattar Date: Sun, 17 Jul 2016 17:04:09 +0530 Subject: [PATCH] Coverity: hdf5 module resource leaks fixed Change-Id: If2521fb6c347791a2f598994ed4d5f73e92e59e2 --- .../hdf5/sci_gateway/cpp/sci_hdf5_load_v2.cpp | 5 +++++ .../hdf5/sci_gateway/cpp/sci_hdf5_load_v3.cpp | 4 ++++ .../modules/hdf5/sci_gateway/cpp/sci_hdf5_save.cpp | 1 + 3 files changed, 10 insertions(+) diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_load_v2.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_load_v2.cpp index 43b5d1e..8d70374 100644 --- a/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_load_v2.cpp +++ b/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_load_v2.cpp @@ -749,6 +749,7 @@ static bool import_integer(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piA } break; default: + FREE(piDims); return false; } @@ -1483,6 +1484,8 @@ static bool import_struct(int* pvCtx, int _iDatasetId, int _iVarType, int _iItem } types::Struct* pStruct = new types::Struct(piDims[1], piDimsArray); + delete[] piDims; + delete[] piDimsArray; wchar_t* pwstName = NULL; for (int i = 0; i < (-2 + iItems); ++i) @@ -1717,6 +1720,8 @@ static bool import_cell(int* pvCtx, int _iDatasetId, int _iVarType, int _iItemPo } types::Cell* pCell = new types::Cell(piDims[1], piDimsArray); + delete[] piDims; + delete[] piDimsArray; types::List* pList = new types::List(); pList->set(0, types::Double::Empty()); diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_load_v3.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_load_v3.cpp index 263ae97..8890968 100644 --- a/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_load_v3.cpp +++ b/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_load_v3.cpp @@ -615,6 +615,7 @@ static types::InternalType* import_struct(int dataset) { closeList6(dataset); freeStringMatrix(dfield, fields.data()); + FREE(field); delete str; return nullptr; } @@ -628,6 +629,7 @@ static types::InternalType* import_struct(int dataset) if (ret < 0) { freeStringMatrix(dfield, fields.data()); + FREE(field); delete str; return nullptr; } @@ -640,6 +642,7 @@ static types::InternalType* import_struct(int dataset) if (data < 0) { freeStringMatrix(dfield, fields.data()); + FREE(field); delete str; return nullptr; } @@ -648,6 +651,7 @@ static types::InternalType* import_struct(int dataset) if (val == nullptr) { freeStringMatrix(dfield, fields.data()); + FREE(field); delete str; return nullptr; } diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_save.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_save.cpp index 78e002d..fe20e38 100644 --- a/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_save.cpp +++ b/scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_save.cpp @@ -518,6 +518,7 @@ static int export_struct(int parent, const std::string& name, types::Struct* dat if (ret) { delete fields; + FREE(cfield); return -1; } } -- 1.7.9.5