mirror of
https://github.com/glest/glest-source.git
synced 2025-08-27 09:54:26 +02:00
- fixed a memory leak in the png reader (using valgrind)
This commit is contained in:
@@ -73,9 +73,11 @@ Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
|
|||||||
}
|
}
|
||||||
png_infop info_ptr = png_create_info_struct(png_ptr);
|
png_infop info_ptr = png_create_info_struct(png_ptr);
|
||||||
if (!info_ptr) {
|
if (!info_ptr) {
|
||||||
|
png_destroy_read_struct(&png_ptr, (png_infopp)NULL,(png_infopp)NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr,(png_infopp)NULL);
|
||||||
return NULL; //Error during init_io
|
return NULL; //Error during init_io
|
||||||
}
|
}
|
||||||
png_set_read_fn(png_ptr, &is, user_read_data);
|
png_set_read_fn(png_ptr, &is, user_read_data);
|
||||||
@@ -167,7 +169,14 @@ Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
|
|||||||
}
|
}
|
||||||
location+=picComponents*width;
|
location+=picComponents*width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int y = 0; y < height; ++y) {
|
||||||
|
delete [] row_pointers[y];
|
||||||
|
}
|
||||||
delete[] row_pointers;
|
delete[] row_pointers;
|
||||||
|
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user