diff --git a/modules/io/src/img/map_io_png_handler.cc b/modules/io/src/img/map_io_png_handler.cc
index 571cecfa907547716b6997e9397dccb04313b4bd..d77db114b4d20c72d026d10e3f6e2435a8737b06 100644
--- a/modules/io/src/img/map_io_png_handler.cc
+++ b/modules/io/src/img/map_io_png_handler.cc
@@ -226,12 +226,12 @@ void MapIOPngHandler::Export(const img::MapHandle& image, std::ostream& f,const
 
   info_ptr = png_create_info_struct(png_ptr);
   if (info_ptr == NULL) {
-    png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
+    png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
     throw IOException("png: error creating info_struct");
   }
 
   if (setjmp(png_jmpbuf(png_ptr))) {
-    png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+    png_destroy_write_struct(&png_ptr, &info_ptr);
     throw IOException("png: error setting jmpbuf");
   }
 
@@ -293,7 +293,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);
 
 }