aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/compext/Png.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c b/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c
index 0a258c5a3..e80f3879d 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c
@@ -253,17 +253,6 @@ char *PngCompressData(XImage *image, int *compressed_size)
NXColorTable color_table[NB_COLOR_MAX];
CARD8 *image_index;
- image_index = (CARD8 *) malloc((image -> height) * (image -> width) * sizeof(CARD8));
-
- /*
- * TODO: Be sure the padded bytes are cleaned.
- * It would be better to set to zero the bytes
- * that are not aligned to the word boundary
- * at the end of the procedure.
- */
-
- memset(image_index, 0, (image -> height) * (image -> width) * sizeof(CARD8));
-
*compressed_size = 0;
pngDataLen = 0;
@@ -283,7 +272,6 @@ char *PngCompressData(XImage *image, int *compressed_size)
bitsPerPixel);
#endif
- free(image_index);
return NULL;
}
@@ -316,7 +304,6 @@ char *PngCompressData(XImage *image, int *compressed_size)
fprintf(stderr, "******PngCompressData: PANIC! Failed creating the png_create_write_struct.\n");
#endif
- free(image_index);
return NULL;
}
@@ -329,7 +316,6 @@ char *PngCompressData(XImage *image, int *compressed_size)
#endif
png_destroy_write_struct(&png_ptr, NULL);
- free(image_index);
return NULL;
}
@@ -341,7 +327,6 @@ char *PngCompressData(XImage *image, int *compressed_size)
#endif
png_destroy_write_struct(&png_ptr, &info_ptr);
- free(image_index);
return NULL;
}
@@ -364,8 +349,6 @@ char *PngCompressData(XImage *image, int *compressed_size)
PNG_DEST_SIZE(w, h));
#endif
- free(image_index);
-
return NULL;
}
@@ -383,6 +366,24 @@ char *PngCompressData(XImage *image, int *compressed_size)
return NULL;
}
+ image_index = (CARD8 *) calloc(1, (image -> height) * (image -> width) * sizeof(CARD8));
+ if (image_index == NULL)
+ {
+ #ifdef PANIC
+ fprintf(stderr, "******PngCompressData: PANIC! Could not alloc image_index.\n");
+ #endif
+
+ free(pngCompBuf);
+ return NULL;
+ }
+
+ /*
+ * TODO: Be sure the padded bytes are cleaned.
+ * It would be better to set to zero the bytes
+ * that are not aligned to the word boundary
+ * at the end of the procedure.
+ */
+
png_set_compression_level(png_ptr, PNG_Z_LEVEL);
if (bitsPerPixel == 16)