This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efl.

View the commit online.

commit 54c65163738f096853c1bbeb5255f9813489d972
Author: Carsten Haitzler <ras...@rasterman.com>
AuthorDate: Sun May 22 09:15:50 2022 +0100

    evas psd loader - don't crash on loading non rgb psd's
    
    at least fail gracefully.
    
    @fix
---
 .../evas/image_loaders/psd/evas_image_load_psd.c   | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/modules/evas/image_loaders/psd/evas_image_load_psd.c b/src/modules/evas/image_loaders/psd/evas_image_load_psd.c
index 58cd961acf..7f397252c2 100644
--- a/src/modules/evas/image_loaders/psd/evas_image_load_psd.c
+++ b/src/modules/evas/image_loaders/psd/evas_image_load_psd.c
@@ -457,23 +457,29 @@ psd_get_data(PSD_Header *head,
      {
         for (x = 0; x < pixels_count; x++)
           {
-             buffer[x * 4 + 0] = data[x * 3 + 2];
-             buffer[x * 4 + 1] = data[x * 3 + 1];
-             buffer[x * 4 + 2] = data[x * 3 + 0];
+             buffer[x * 4 + 0] = data[(x * 3) + 2];
+             buffer[x * 4 + 1] = data[(x * 3) + 1];
+             buffer[x * 4 + 2] = data[(x * 3) + 0];
              buffer[x * 4 + 3] = 255;
           }
      }
-   else
+   else if (bpp == 4)
      {
         // BRGA to RGBA
         for (x= 0; x < pixels_count; x++)
           {
-             buffer[x * 4 + 0] = data[x * 4 + 2];
-             buffer[x * 4 + 1] = data[x * 4 + 1];
-             buffer[x * 4 + 2] = data[x * 4 + 0];
-             buffer[x * 4 + 3] = data[x * 4 + 3];
+             buffer[x * 4 + 0] = data[(x * 4) + 2];
+             buffer[x * 4 + 1] = data[(x * 4) + 1];
+             buffer[x * 4 + 2] = data[(x * 4) + 0];
+             buffer[x * 4 + 3] = data[(x * 4) + 3];
           }
      }
+   else
+     {
+        // can;'t handle non rgb formats
+        *error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
+        goto file_read_error;
+     }
 
    free(channel);
    free(data);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to