diff --git a/modules/io/src/img/map_io_png_handler.cc b/modules/io/src/img/map_io_png_handler.cc
index e16f12ed3b4643e273b6022d14d6297260450c1a..58cf49ee9e78de22a5d9ebeea5c04ccc4aeaa55d 100644
--- a/modules/io/src/img/map_io_png_handler.cc
+++ b/modules/io/src/img/map_io_png_handler.cc
@@ -286,7 +286,7 @@ void MapIOPngHandler::Export(const img::MapHandle& image, std::ostream& f,const
 
   png_write_end(png_ptr, info_ptr);
 
-  png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
+  png_destroy_write_struct(&png_ptr, &info_ptr);
 
 }