8c18b08ac5
All fixes from/via NetBSD pkgsrc. The people there did a lot of heavy lifting.
95 lines
3.1 KiB
Plaintext
95 lines
3.1 KiB
Plaintext
$OpenBSD: patch-Imlib_utils_c,v 1.4 2011/07/08 20:36:09 naddy Exp $
|
|
--- Imlib/utils.c.orig Fri Mar 22 07:43:04 2002
|
|
+++ Imlib/utils.c Mon Jul 4 17:36:44 2011
|
|
@@ -801,6 +801,7 @@ Imlib_crop_and_clone_image(ImlibData * id, ImlibImage
|
|
unsigned char *ptr1, *ptr2;
|
|
ImlibImage *im2;
|
|
char *s;
|
|
+ size_t s_size;
|
|
|
|
if (!im)
|
|
return NULL;
|
|
@@ -872,10 +873,11 @@ Imlib_crop_and_clone_image(ImlibData * id, ImlibImage
|
|
im2->rgb_width = w;
|
|
im2->rgb_height = h;
|
|
im2->alpha_data = NULL;
|
|
- s = malloc(strlen(im->filename) + 320);
|
|
+ s_size = strlen(im->filename + 320);
|
|
+ s = malloc(s_size);
|
|
if (s)
|
|
{
|
|
- snprintf(s, sizeof(s), "%s_%x_%x", im->filename, (int)time(NULL), (int)rand());
|
|
+ snprintf(s, s_size, "%s_%x_%x", im->filename, (int)time(NULL), (int)rand());
|
|
im2->filename = malloc(strlen(s) + 1);
|
|
if (im2->filename)
|
|
strcpy(im2->filename, s);
|
|
@@ -1211,6 +1213,7 @@ Imlib_clone_image(ImlibData * id, ImlibImage * im)
|
|
{
|
|
ImlibImage *im2;
|
|
char *s;
|
|
+ size_t s_size;
|
|
|
|
if (!im)
|
|
return NULL;
|
|
@@ -1239,10 +1242,11 @@ Imlib_clone_image(ImlibData * id, ImlibImage * im)
|
|
}
|
|
else
|
|
im2->alpha_data = NULL;
|
|
- s = malloc(strlen(im->filename) + 320);
|
|
+ s_size = strlen(im->filename) + 320;
|
|
+ s = malloc(s_size);
|
|
if (s)
|
|
{
|
|
- snprintf(s, sizeof(s), "%s_%x_%x", im->filename, (int)time(NULL), (int)rand());
|
|
+ snprintf(s, s_size, "%s_%x_%x", im->filename, (int)time(NULL), (int)rand());
|
|
im2->filename = malloc(strlen(s) + 1);
|
|
if (im2->filename)
|
|
strcpy(im2->filename, s);
|
|
@@ -1285,6 +1289,7 @@ Imlib_clone_scaled_image(ImlibData * id, ImlibImage *
|
|
{
|
|
ImlibImage *im2;
|
|
char *s;
|
|
+ size_t s_size;
|
|
|
|
if ((!im) || (w <= 0) || (h <= 0))
|
|
return NULL;
|
|
@@ -1417,10 +1422,11 @@ Imlib_clone_scaled_image(ImlibData * id, ImlibImage *
|
|
}
|
|
else
|
|
im2->alpha_data = NULL;
|
|
- s = malloc(strlen(im->filename) + 320);
|
|
+ s_size = strlen(im->filename) + 320;
|
|
+ s = malloc(s_size);
|
|
if (s)
|
|
{
|
|
- snprintf(s, sizeof(s), "%s_%x_%x_%x_%x", im->filename, (int)time(NULL), w, h, (int)rand());
|
|
+ snprintf(s, s_size, "%s_%x_%x_%x_%x", im->filename, (int)time(NULL), w, h, (int)rand());
|
|
im2->filename = malloc(strlen(s) + 1);
|
|
if (im2->filename)
|
|
strcpy(im2->filename, s);
|
|
@@ -1596,7 +1602,7 @@ Imlib_create_image_from_xpm_data(ImlibData * id, char
|
|
{
|
|
if (line[k] != ' ')
|
|
{
|
|
- sscanf(&line[k], "%65536s", s);
|
|
+ sscanf(&line[k], "%255s", s);
|
|
k += strlen(s);
|
|
if (!strcmp(s, "c"))
|
|
iscolor = 1;
|
|
@@ -1959,13 +1965,13 @@ Imlib_inlined_png_to_image(ImlibData *id, unsigned cha
|
|
return NULL;
|
|
}
|
|
|
|
- if (setjmp(png_ptr->jmpbuf))
|
|
+ if (setjmp(png_jmpbuf(png_ptr)))
|
|
{
|
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
|
return NULL;
|
|
}
|
|
|
|
- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
|
+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB_ALPHA)
|
|
{
|
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
|
return NULL;
|