Enlightenment CVS committal

Author  : kwo
Project : e17
Module  : libs/imlib2

Dir     : e17/libs/imlib2/src/modules/loaders


Modified Files:
        loader_argb.c loader_bmp.c loader_jpeg.c loader_lbm.c 
        loader_xpm.c 


Log Message:
Various loader fixes (Marcus Meissner, bug 494).

===================================================================
RCS file: /cvs/e/e17/libs/imlib2/src/modules/loaders/loader_argb.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- loader_argb.c       9 Apr 2007 12:55:29 -0000       1.4
+++ loader_argb.c       18 Jun 2008 17:52:38 -0000      1.5
@@ -10,7 +10,7 @@
 load(ImlibImage * im, ImlibProgressFunction progress,
      char progress_granularity, char immediate_load)
 {
-   int                 w, h, alpha;
+   int                 w = 0, h = 0, alpha = 0;
    FILE               *f;
 
    if (im->data)
@@ -23,11 +23,13 @@
    {
       char                buf[256], buf2[256];
 
+      buf[0] = '\0';
       if (!fgets(buf, 255, f))
         {
            fclose(f);
            return 0;
         }
+      buf2[0] = '\0';
       sscanf(buf, "%s %i %i %i", buf2, &w, &h, &alpha);
       if (strcmp(buf2, "ARGB"))
         {
===================================================================
RCS file: /cvs/e/e17/libs/imlib2/src/modules/loaders/loader_bmp.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- loader_bmp.c        15 Jul 2007 08:28:11 -0000      1.10
+++ loader_bmp.c        18 Jun 2008 17:52:38 -0000      1.11
@@ -565,7 +565,7 @@
                   unsigned char *buffer_end_minus_1 = buffer_end - 1;
                   x = 0;
                   y = 0;
-                  for (i = 0; i < imgsize && buffer_ptr < buffer_end_minus_1 
&& g; i++)
+                  for (i = 0; i < imgsize && buffer_ptr < buffer_end_minus_1; 
i++)
                     {
                        byte1 = buffer_ptr[0];
                        byte2 = buffer_ptr[1];
===================================================================
RCS file: /cvs/e/e17/libs/imlib2/src/modules/loaders/loader_jpeg.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- loader_jpeg.c       9 Apr 2007 12:55:29 -0000       1.5
+++ loader_jpeg.c       18 Jun 2008 17:52:38 -0000      1.6
@@ -78,6 +78,7 @@
         im->h = h = cinfo.output_height;
        if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
          {
+             im->w = im->h = 0;
              jpeg_destroy_decompress(&cinfo);
              fclose(f);
              return 0;
@@ -96,6 +97,7 @@
 
         if (cinfo.rec_outbuf_height > 16)
           {
+             im->w = im->h = 0;
              jpeg_destroy_decompress(&cinfo);
              fclose(f);
              return 0;
@@ -103,6 +105,7 @@
         data = malloc(w * 16 * 3);
         if (!data)
           {
+             im->w = im->h = 0;
              jpeg_destroy_decompress(&cinfo);
              fclose(f);
              return 0;
@@ -111,6 +114,7 @@
         ptr2 = im->data = malloc(w * h * sizeof(DATA32));
         if (!im->data)
           {
+             im->w = im->h = 0;
              free(data);
              jpeg_destroy_decompress(&cinfo);
              fclose(f);
===================================================================
RCS file: /cvs/e/e17/libs/imlib2/src/modules/loaders/loader_lbm.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- loader_lbm.c        9 Apr 2007 12:55:29 -0000       1.4
+++ loader_lbm.c        18 Jun 2008 17:52:38 -0000      1.5
@@ -437,6 +437,7 @@
         }
     }
     if (!full || !ok) {
+        im->w = im->h = 0;
         freeilbm(&ilbm);
         return ok;
     }
@@ -452,11 +453,11 @@
     plane[0] = NULL;
 
     im->data = malloc(im->w * im->h * sizeof(DATA32));
-    if (im->data) {
-        n = ilbm.depth;
+    n = ilbm.depth;
+    plane[0] = malloc(((im->w + 15) / 16) * 2 * n);
+    if (im->data && plane[0]) {
         if (ilbm.mask == 1) n++;
 
-        plane[0] = malloc(((im->w + 15) / 16) * 2 * n);
         for (i = 1; i < n; i++) plane[i] = plane[i - 1] + ((im->w + 15) / 16) 
* 2;
 
         z = ((im->w + 15) / 16) * 2 * n;
@@ -492,9 +493,10 @@
 
   /*----------
    * We either had a successful decode, the user cancelled, or we couldn't get
-   * the memory for im->data.
+   * the memory for im->data or plane[0].
    *----------*/
     if (!ok) {
+        im->w = im->h = 0;
         if (im->data) free(im->data);
         im->data = NULL;
     }
===================================================================
RCS file: /cvs/e/e17/libs/imlib2/src/modules/loaders/loader_xpm.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- loader_xpm.c        13 Jun 2008 22:39:27 -0000      1.10
+++ loader_xpm.c        18 Jun 2008 17:52:38 -0000      1.11
@@ -153,6 +153,9 @@
    pixels = 0;
    count = 0;
    line = malloc(lsz);
+   if (!line)
+     return NULL;
+
    backslash = 0;
    memset(lookup, 0, sizeof(lookup));
    while (!done)



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to