]> git.imager.perl.org - imager.git/blobdiff - palimg.c
- use a temp file to avoid messing with echo on Win32 when building
[imager.git] / palimg.c
index ecb14660c1a4c5e07054225d19fd2f1729b8a5d5..1667238ec57b0d3bf94f47044526a3a48122be1e 100644 (file)
--- a/palimg.c
+++ b/palimg.c
@@ -127,7 +127,12 @@ i_img *i_img_pal_new(int x, int y, int channels, int maxpal) {
   i_img *im;
   mm_log((1, "i_img_pal_new(x %d, y %d, channels %d, maxpal %d)\n", x, y, channels, maxpal));
   im = mymalloc(sizeof(i_img));
-  return i_img_pal_new_low(im, x, y, channels, maxpal);
+  if (!i_img_pal_new_low(im, x, y, channels, maxpal)) {
+    myfree(im);
+    im = NULL;
+  }
+
+  return im;
 }
 
 /*
@@ -165,8 +170,6 @@ The conversion cannot be done for virtual images.
 */
 int i_img_to_rgb_inplace(i_img *im) {
   i_img temp;
-  i_color *pal;
-  int palsize;
 
   if (im->virtual)
     return 0;
@@ -336,7 +339,7 @@ RGB.
 =cut
 */
 static int i_plin_p(i_img *im, int l, int r, int y, i_color *vals) {
-  int ch, count, i;
+  int count, i;
   i_palidx *data;
   i_palidx which;
   if (y >=0 && y < im->ysize && l < im->xsize && l >= 0) {
@@ -534,7 +537,7 @@ static int i_maxcolors_p(i_img *im) {
 =cut
 */
 static int i_setcolors_p(i_img *im, int index, i_color *colors, int count) {
-  if (index >= 0 && count >= 1 && index + count < PALEXT(im)->count) {
+  if (index >= 0 && count >= 1 && index + count <= PALEXT(im)->count) {
     while (count) {
       PALEXT(im)->pal[index++] = *colors++;
       --count;