check alloc
[dos_imgv] / imago / src / filejpeg.c
index f7139c6..d9cf26f 100644 (file)
@@ -31,6 +31,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <jpeglib.h>
 #include "imago2.h"
 #include "ftmodule.h"
+#include "chkalloc.h"
 
 #define INPUT_BUF_SIZE 512
 #define OUTPUT_BUF_SIZE        512
@@ -125,7 +126,7 @@ static int read(struct img_pixmap *img, struct img_io *io)
                return -1;
        }
 
-       if(!(scanlines = malloc(img->height * sizeof *scanlines))) {
+       if(!(scanlines = chk_malloc(img->height * sizeof *scanlines))) {
                jpeg_destroy_decompress(&cinfo);
                return -1;
        }
@@ -142,7 +143,7 @@ static int read(struct img_pixmap *img, struct img_io *io)
        jpeg_finish_decompress(&cinfo);
        jpeg_destroy_decompress(&cinfo);
 
-       free(scanlines);
+       chk_free(scanlines);
        return 0;
 }
 
@@ -168,7 +169,7 @@ static int write(struct img_pixmap *img, struct img_io *io)
                img = &tmpimg;
        }
 
-       if(!(scanlines = malloc(img->height * sizeof *scanlines))) {
+       if(!(scanlines = chk_malloc(img->height * sizeof *scanlines))) {
                img_destroy(&tmpimg);
                return -1;
        }
@@ -202,7 +203,7 @@ static int write(struct img_pixmap *img, struct img_io *io)
        jpeg_finish_compress(&cinfo);
        jpeg_destroy_compress(&cinfo);
 
-       free(scanlines);
+       chk_free(scanlines);
        img_destroy(&tmpimg);
        return 0;
 }