Updates will be applied - 3:30pm EDT (UTC -400). No downtime expected.

Commit 33d36220 authored by camp's avatar camp

Fix memory leaks, fix mismatching allocation and deallocation, need to close files.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@13498 18c085ea-50e0-402c-830e-de6fd14e8384
parent 24b47c17
......@@ -851,7 +851,7 @@ AddEnvironment(const int useShortFileName, const int addPluginVars)
}
}
/*
* Determine if this is is dev version
* Determine if this is dev version
*/
{
string vp(visitpath);
......@@ -869,10 +869,10 @@ AddEnvironment(const int useShortFileName, const int addPluginVars)
if (pos <= 0)
pos = len;
visitdevdir = (char*)malloc(pos +12);
visitdevdir = (char*)malloc(pos + 14);
strncpy(visitdevdir, visitpath, pos);
visitdevdir[pos] = '\0';
sprintf(visitdevdir,"%s\\ThirdParty", visitdevdir);
strncat(visitdevdir, "\\ThirdParty", 14);
}
}
......
......@@ -1627,6 +1627,8 @@ avtCaleFileFormat::GetAuxiliaryData(const char *var,
else
{
debug4 << "nreg < 1. No material information" << endl;
delete [] names; // top
delete [] matnos;
}
df = avtMaterial::Destruct;
}
......
......@@ -224,6 +224,7 @@ int vtkVisItEnSightGoldBinaryReader::ReadGeometryFile(const char* fileName, int
char *name = strdup(line);
if (strncmp(line, "interface", 9) == 0)
{
if (name) free(name);
return 1; // ignore it and move on
}
this->ReadLine(line);
......
......@@ -152,6 +152,7 @@ int vtkVisItEnSightGoldReader::ReadGeometryFile(const char* fileName, int timeSt
char *name = strdup(line);
if (strncmp(line, "interface", 9) == 0)
{
if(name) free( name );
return 1; // ignore it and move on
}
......
......@@ -4920,6 +4920,10 @@ void gmvread_mesh()
if (gmv_data.keyword == CELLS) rdcells(nodetype_in);
if (gmv_data.keyword == FACES) rdfaces();
if (gmv_data.keyword == XFACES) rdxfaces();
if (xin) free(xin);
if (yin) free(yin);
if (zin) free(zin);
}
......
......@@ -650,7 +650,7 @@ void H5_Index::create_dataset(const std::vector<int64_t> dims,
//read out the data to the new file
dataset_id.write(H5T_NATIVE_FLOAT,temp_float);
//release the memory
delete temp_float;
delete [] temp_float;
//create the attribute
dataspace_id.create(1,&temp_size);
attribute_id.create(dataset_id.getID(),"DataSetMinValue",
......@@ -678,7 +678,7 @@ void H5_Index::create_dataset(const std::vector<int64_t> dims,
//read out the data to the new file
dataset_id.write(H5T_NATIVE_DOUBLE,temp_double);
//release the memory
delete temp_double;
delete [] temp_double;
//create the attribute
dataspace_id.create(1,&temp_size);
attribute_id.create(dataset_id.getID(),"DataSetMinValue",
......@@ -707,7 +707,7 @@ void H5_Index::create_dataset(const std::vector<int64_t> dims,
//read out the data to the new file
dataset_id.write(H5T_NATIVE_INT32,temp_int);
//release the memory
delete temp_int;
delete [] temp_int;
//create the attribute
dataspace_id.create(1,&temp_size);
attribute_id.create(dataset_id.getID(),"DataSetMinValue",
......@@ -736,7 +736,7 @@ void H5_Index::create_dataset(const std::vector<int64_t> dims,
//read out the data to the new file
dataset_id.write(H5T_NATIVE_INT64,temp_lng);
//release the memory
delete temp_lng;
delete [] temp_lng;
//create the attribute
dataspace_id.create(1,&temp_size);
attribute_id.create(dataset_id.getID(),"DataSetMinValue",
......@@ -765,7 +765,7 @@ void H5_Index::create_dataset(const std::vector<int64_t> dims,
//read out the data to the new file
dataset_id.write(H5T_NATIVE_CHAR,temp_chr);
//release the memory
delete temp_chr;
delete [] temp_chr;
//create the attribute
dataspace_id.create(1,&temp_size);
attribute_id.create(dataset_id.getID(),"DataSetMinValue",
......@@ -795,7 +795,7 @@ void H5_Index::create_dataset(const std::vector<int64_t> dims,
attribute_id.write(H5T_NATIVE_INT64,&new_dataset);
//close the attribute data
delete size;
delete [] size;
}
// create a uint32_t array with [nelements] elements and fill them with 0.
......@@ -836,14 +836,22 @@ bool H5_Index::createBitmap(const std::string& variableName,
answer = dataset_id.create(group_id.getID(),file_path.c_str(),
H5T_NATIVE_UINT32,dataspace_id.getID());
if (answer == false) return answer;
if (answer == false)
{
delete [] temp_int;
return answer;
}
//read out the data to the new file
answer = dataset_id.write(H5T_NATIVE_UINT32,temp_int);
if (answer == false) return answer;
if (answer == false)
{
delete [] temp_int;
return answer;
}
//release the memory from the three datasets
delete temp_int;
delete [] temp_int;
//determine the type of the original data...
BaseFileInterface::DataType type;
......
......@@ -307,7 +307,7 @@ void* get_values( const char *signal, int dtype ) {
char buf[1024]; /* buffer for MDS+ exp */
int len, dsc; /* Used in MDS+ calls */
int null = 0;
int *dims;
int *dims = NULL;
int cc, i, n, size = 1;
void* values;
......@@ -317,12 +317,18 @@ void* get_values( const char *signal, int dtype ) {
int rank = get_dims( signal, &dims );
if( rank < 0 )
{
if( dims ) free( dims );
return NULL;
}
if( rank == 0 )
{
if( dims ) free( dims );
return get_value( signal, dtype );
}
for( i=0; i<rank; i++ )
size *= dims[i];
......@@ -522,7 +528,7 @@ get_names( const char *signal, char **names,
sprintf( buf, "GETNCI(\"\\%s%s\", \"%s\", \"%s\")",
signal, wildcard, path, item );
int *dims;
int *dims = NULL;
int rank = get_dims( buf, &dims );
if( rank > 0 ) {
......@@ -533,8 +539,10 @@ get_names( const char *signal, char **names,
*names = (char*) get_values( buf, DTYPE_CSTRING );
if( dims ) free( dims );
return nnames;
} else {
if( dims ) free( dims );
return 0;
}
}
......
......@@ -2652,7 +2652,10 @@ avtNek5000FileFormat::GetBoundingBoxIntervalTree(int timestep)
errorReadingData = anyErrorReadingData;
#endif
if (errorReadingData)
{
delete[] bounds;
return NULL;
}
#ifdef PARALLEL
float *mergedBounds = new float[iNumBlocks*6];
......@@ -2899,7 +2902,10 @@ avtNek5000FileFormat::GetDataExtentsIntervalTree(int timestep, const char *var)
errorReadingData = anyErrorReadingData;
#endif
if (errorReadingData)
{
delete[] bounds;
return NULL;
}
#ifdef PARALLEL
float *mergedBounds = new float[iNumBlocks*2];
......
......@@ -2582,8 +2582,6 @@ PF3DFileFormat::MasterInformation::Read(PDBFileObject *pdb)
//
if (ndims != 2)
{
// Make an array of the proper size
double *xyzloc = new double[6*ndom*sizeof(double)];
// get a pointer to the domloc array
long *domloc = 0;
for (int it = 0; it < members.size(); ++it)
......@@ -2600,6 +2598,8 @@ PF3DFileFormat::MasterInformation::Read(PDBFileObject *pdb)
debug4 << mName << " domloc is not present in the master file" << endl;
return false;
}
// Make an array of the proper size
double *xyzloc = new double[6*ndom*sizeof(double)];
double xyzbase[6];
memcpy(xyzbase, members[i]->data, 6*sizeof(double));
for (int id = 0; id < ndom; ++id)
......
......@@ -2521,6 +2521,7 @@ int vtkVisItPLOT3DReader::ReadNumbers( FILE *fp, unsigned int numbersToRead,
double * doubleOutput = new double[numbersToRead];
if ((fread(doubleOutput,sizeof(double),numbersToRead,fp))<numbersToRead)
{
if (doubleOutput) delete [] doubleOutput;
return 1;
}
else
......
......@@ -65,11 +65,13 @@ main(int argc, char *argv[])
else if(code == esriFileErrorInvalidFile)
{
fprintf(outputLog, "The file was not an ESRI shape file!\n");
fclose(outputLog);
return -1;
}
else
{
fprintf(outputLog, "Could not open the file!\n");
fclose(outputLog);
return -1;
}
......
......@@ -649,7 +649,10 @@ avtSimV2Writer::WriteUnstructuredMesh(vtkUnstructuredGrid *ds, int chunk,
{
visit_handle h = VISIT_INVALID_HANDLE;
if(simv2_UnstructuredMesh_alloc(&h) == VISIT_ERROR)
{
delete [] cellCopy;
return;
}
// Send the coordinates down to the writer interleaved.
visit_handle hc;
......
......@@ -379,6 +379,7 @@ avtTSurfFileFormat::ReadFile(const char *name, int nLines)
// the size of the file.
nPoints = fileSize / 60;
nCells = fileSize / 45;
fclose(fp);
#endif
}
vtkPoints *pts = vtkPoints::New();
......
......@@ -1812,6 +1812,8 @@ int vtkVisItDataReader::ReadCells(int size, int *data,
{
vtkErrorMacro(<<"Error reading binary cell data!" << " for file: "
<< this->FileName);
if (tmp != data)
delete [] tmp;
return 0;
}
vtkByteSwap::Swap4BERange(tmp,size);
......
......@@ -280,7 +280,10 @@ int read_int2_array( int f, short *iarray, int n )
buffer = (signed char *) malloc( n * 2 );
if (!buffer) return 0;
nread = read( f, buffer, n*2 );
if (nread<=0) return 0;
if (nread<=0) {
free( buffer );
return 0;
}
nread /= 2;
for (i=0;i<nread;i++) {
/* don't forget about sign extension! */
......@@ -317,7 +320,10 @@ int read_uint2_array( int f, unsigned short *iarray, int n )
buffer = (unsigned char *) malloc( n * 2 );
if (!buffer) return 0;
nread = read( f, buffer, n*2 );
if (nread<=0) return 0;
if (nread<=0) {
free( buffer );
return 0;
}
nread /= 2;
for (i=0;i<nread;i++) {
iarray[i] = (buffer[i*2] << 8) | buffer[i*2+1];
......@@ -388,6 +394,7 @@ int read_int4_array( int f, int *iarray, int n )
return 0;
nread = read( f, buffer, 4*n );
if (nread<=0) {
free( buffer );
return 0;
}
nread /= 4;
......@@ -473,7 +480,10 @@ int read_float4_array( int f, float *x, int n )
buffer = (long *) malloc( (n+1) * 4 );
if (!buffer) return 0;
nread = read( f, buffer, n*4 );
if (nread<=0) return 0;
if (nread<=0) {
free( buffer );
return 0;
}
nread /= 4;
ieee_to_cray_array( x, buffer, nread );
free( buffer );
......
......@@ -2104,6 +2104,7 @@ v5dstruct *v5dOpenFile( const char *filename, v5dstruct *v )
else {
v = v5dNewStruct();
if (!v) {
close(fd);
return NULL;
}
}
......@@ -2111,9 +2112,11 @@ v5dstruct *v5dOpenFile( const char *filename, v5dstruct *v )
v->FileDesc = fd;
v->Mode = 'r';
if (read_v5d_header( v )) {
close(fd);
return v;
}
else {
close(fd);
return NULL;
}
}
......@@ -2497,6 +2500,7 @@ v5dstruct *v5dUpdateFile( const char *filename, v5dstruct *v )
if (!v) {
v = v5dNewStruct();
if (!v) {
close(fd);
return NULL;
}
}
......@@ -2505,9 +2509,11 @@ v5dstruct *v5dUpdateFile( const char *filename, v5dstruct *v )
v->Mode = 'w';
if (read_v5d_header( v )) {
close(fd);
return v;
}
else {
close(fd);
return NULL;
}
}
......
......@@ -118,7 +118,7 @@ herr_t VsH5Attribute::getIntVectorValue(std::vector<int>* ivals) {
for (size_t i = 0; i<npoints; ++i) {
(*ivals)[i] = v[i];
}
delete v;
delete [] v;
return err;
}
......@@ -157,7 +157,7 @@ herr_t VsH5Attribute::getFloatVectorValue(std::vector<float>* fvals) {
for (size_t i = 0; i<npoints; ++i) {
(*fvals)[i] = v[i];
}
delete v;
delete [] v;
return err;
}
......@@ -195,7 +195,7 @@ herr_t VsH5Attribute::getDoubleVectorValue(std::vector<double>* dvals) {
for (size_t i = 0; i<npoints; ++i) {
(*dvals)[i] = v[i];
}
delete v;
delete [] v;
return err;
}
......@@ -814,6 +814,8 @@ QvisCMap2Display::getAlpha(WidgetID id) const
IdToWidgetMap::const_iterator it = idToWidget.find(id);
if(it != idToWidget.end())
retval = it.value()->get_alpha();
else
retval = 0.0;
return retval;
}
......
......@@ -260,6 +260,7 @@ int cmdline_process_param(char *p, char *value, int need_save, Config *cfg)
cfg->remote_cmd_ptr = command;
cfg->remote_cmd_ptr2 = NULL;
cfg->nopty = TRUE; /* command => no terminal */
fclose(fp);
}
if (!strcmp(p, "-P")) {
RETURN(2);
......
......@@ -442,6 +442,10 @@ class IntArray : public virtual Field
length = s.toInt();
val = new int[length];
}
virtual ~IntArray()
{
if( val ) delete [] val;
}
virtual QString GetCPPName(bool, const QString &)
{
return "int";
......@@ -602,6 +606,10 @@ class FloatArray : public virtual Field
length = s.toInt();
val = new float[length];
}
virtual ~FloatArray()
{
if( val ) delete [] val;
}
virtual QString GetCPPName(bool, const QString &)
{
return "float";
......@@ -682,6 +690,10 @@ class DoubleArray : public virtual Field
length = s.toInt();
val = new double[length];
}
virtual ~DoubleArray()
{
if( val ) delete [] val;
}
virtual QString GetCPPName(bool, const QString &)
{
return "double";
......@@ -809,6 +821,10 @@ class UCharArray : public virtual Field
length = s.toInt();
val = new unsigned char[length];
}
virtual ~UCharArray()
{
if( val ) delete [] val;
}
virtual QString GetCPPName(bool, const QString &)
{
return "unsigned char";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment