409
/* Shield against potential buffer overflows in load_*() functions. */
410
if (G_MAXSIZE / width / height < 3)
412
g_message (_("Image dimensions too large: width %d x height %d"), width, height);
409
416
if (pcx_header.planes == 3 && pcx_header.bpp == 8)
411
418
image= gimp_image_new (width, height, GIMP_RGB);
426
433
if (pcx_header.planes == 1 && pcx_header.bpp == 1)
428
dest = (guchar *) g_malloc (width * height);
435
dest = g_new (guchar, ((gsize) width) * height);
429
436
load_1 (fd, width, height, dest, bytesperline);
430
437
gimp_image_set_colormap (image, mono, 2);
432
439
else if (pcx_header.planes == 4 && pcx_header.bpp == 1)
434
dest = (guchar *) g_malloc (width * height);
441
dest = g_new (guchar, ((gsize) width) * height);
435
442
load_4 (fd, width, height, dest, bytesperline);
436
443
gimp_image_set_colormap (image, pcx_header.colormap, 16);
438
445
else if (pcx_header.planes == 1 && pcx_header.bpp == 8)
440
dest = (guchar *) g_malloc (width * height);
447
dest = g_new (guchar, ((gsize) width) * height);
441
448
load_8 (fd, width, height, dest, bytesperline);
442
449
fseek (fd, -768L, SEEK_END);
443
450
fread (cmap, 768, 1, fd);
446
453
else if (pcx_header.planes == 3 && pcx_header.bpp == 8)
448
dest = (guchar *) g_malloc (width * height * 3);
455
dest = g_new (guchar, ((gsize) width) * height * 3);
449
456
load_24 (fd, width, height, dest, bytesperline);