diff --git a/Geo/ChainComplex.cpp b/Geo/ChainComplex.cpp index 378e85c193ab5cd4d9fec9203ec521a2f1ebd81c..eef0be44ea9b92cf445deb917a4fca6c950db2cc 100644 --- a/Geo/ChainComplex.cpp +++ b/Geo/ChainComplex.cpp @@ -218,6 +218,7 @@ void ChainComplex::Inclusion(int lowDim, int highDim) gmp_matrix_get_elem(elem, i, i, normalForm->canonical); if(mpz_cmp_si(elem,0) == 0){ + destroy_gmp_matrix(Bbasis); destroy_gmp_normal_form(normalForm); return; } @@ -251,6 +252,7 @@ void ChainComplex::Inclusion(int lowDim, int highDim) else { destroy_gmp_matrix(Zbasis); destroy_gmp_matrix(LB); + destroy_gmp_normal_form(normalForm); return; } } diff --git a/Geo/GModelIO_MSH2.cpp b/Geo/GModelIO_MSH2.cpp index 2c796db92ebe2fe6862eb98646a22ebf2862f312..21e09d9998a86e89ddbd49ec98effc471e59dd43 100644 --- a/Geo/GModelIO_MSH2.cpp +++ b/Geo/GModelIO_MSH2.cpp @@ -409,8 +409,13 @@ int GModel::_readMSH2(const std::string &name) } } int *indices = new int[numVertices]; - for(int j = 0; j < numVertices; j++) - if(fscanf(fp, "%d", &indices[j]) != 1){ fclose(fp); return 0; } + for(int j = 0; j < numVertices; j++){ + if(fscanf(fp, "%d", &indices[j]) != 1){ + delete [] indices; + fclose(fp); + return 0; + } + } std::vector<MVertex*> vertices; if(vertexVector.size()){ if(!getVertices(numVertices, indices, vertexVector, vertices, minVertex)){ @@ -521,7 +526,11 @@ int GModel::_readMSH2(const std::string &name) unsigned int n = 1 + numTags + numVertices; int *data = new int[n]; for(int i = 0; i < numElms; i++) { - if(fread(data, sizeof(int), n, fp) != n){ fclose(fp); return 0; } + if(fread(data, sizeof(int), n, fp) != n){ + delete [] data; + fclose(fp); + return 0; + } if(swap) SwapBytes((char*)data, sizeof(int), n); int num = data[0]; int physical = (numTags > 0) ? data[1] : 0;