evas psd loader - don't crash on loading non rgb psd's

at least fail gracefully.

@fix
This commit is contained in:
Carsten Haitzler 2022-05-22 09:15:50 +01:00
parent 0dc787ee6b
commit 54c6516373
1 changed files with 14 additions and 8 deletions

View File

@ -457,23 +457,29 @@ psd_get_data(PSD_Header *head,
{ {
for (x = 0; x < pixels_count; x++) for (x = 0; x < pixels_count; x++)
{ {
buffer[x * 4 + 0] = data[x * 3 + 2]; buffer[x * 4 + 0] = data[(x * 3) + 2];
buffer[x * 4 + 1] = data[x * 3 + 1]; buffer[x * 4 + 1] = data[(x * 3) + 1];
buffer[x * 4 + 2] = data[x * 3 + 0]; buffer[x * 4 + 2] = data[(x * 3) + 0];
buffer[x * 4 + 3] = 255; buffer[x * 4 + 3] = 255;
} }
} }
else else if (bpp == 4)
{ {
// BRGA to RGBA // BRGA to RGBA
for (x= 0; x < pixels_count; x++) for (x= 0; x < pixels_count; x++)
{ {
buffer[x * 4 + 0] = data[x * 4 + 2]; buffer[x * 4 + 0] = data[(x * 4) + 2];
buffer[x * 4 + 1] = data[x * 4 + 1]; buffer[x * 4 + 1] = data[(x * 4) + 1];
buffer[x * 4 + 2] = data[x * 4 + 0]; buffer[x * 4 + 2] = data[(x * 4) + 0];
buffer[x * 4 + 3] = data[x * 4 + 3]; 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(channel);
free(data); free(data);