memory leak when failing to write with vtkPNGWriter
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
There are some memory leaks if a vtkPNGWriter fails to write a file if we are out of disk space.
Here comes a diff patch to avoid this:
@@ -198,6 +198,8 @@ this->TempFP = 0;
- png_byte **row_pointers;
- if (this->WriteToMemory) { vtkUnsignedCharArray *uc = this->GetResult(); @@ -227,6 +229,9 @@ if (setjmp(png_ptr->jmpbuf)) { fclose(this->TempFP);
-
if(row_pointers)
-
delete [] row_pointers;
-
png_destroy_write_struct(&png_ptr, &info_ptr); this->SetErrorCode(vtkErrorCode::OutOfDiskSpaceError); return; }
@@ -272,7 +277,7 @@ png_set_swap(png_ptr); #endif }
- png_byte **row_pointers = new png_byte *[height];
- row_pointers = new png_byte *[height]; vtkIdType *outInc = data->GetIncrements(); vtkIdType rowInc = outInc[1]*bit_depth/8; for (ui = 0; ui < height; ui++)