check alloc
[dos_imgv] / imago / src / filepng.c
index 077b2ba..dcba12d 100644 (file)
@@ -24,6 +24,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <png.h>
 #include "imago2.h"
 #include "ftmodule.h"
+#include "chkalloc.h"
 
 static int check_file(struct img_io *io);
 static int read_file(struct img_pixmap *img, struct img_io *io);
@@ -175,7 +176,7 @@ static int write_file(struct img_pixmap *img, struct img_io *io)
                        PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
        png_set_text(png, info, &txt, 1);
 
-       if(!(rows = malloc(img->height * sizeof *rows))) {
+       if(!(rows = chk_malloc(img->height * sizeof *rows))) {
                png_destroy_write_struct(&png, &info);
                img_destroy(&tmpimg);
                return -1;
@@ -192,7 +193,7 @@ static int write_file(struct img_pixmap *img, struct img_io *io)
        png_write_end(png, info);
        png_destroy_write_struct(&png, &info);
 
-       free(rows);
+       chk_free(rows);
 
        img_destroy(&tmpimg);
        return 0;