mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
Improve error handling in some image loading functions
This commit is contained in:
parent
396b08513a
commit
405ac5ebe5
@ -100,7 +100,11 @@ static bool rpng_image_load_argb_shift(const char *path,
|
||||
&out_img->pixels, &out_img->width, &out_img->height);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
out_img->pixels = NULL;
|
||||
out_img->width = out_img->height = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
texture_image_color_convert(r_shift, g_shift, b_shift,
|
||||
a_shift, out_img);
|
||||
|
@ -36,7 +36,7 @@ bool rtga_image_load_shift(uint8_t *buf,
|
||||
if (buf[2] != 2)
|
||||
{
|
||||
fprintf(stderr, "TGA image is not uncompressed RGB.\n");
|
||||
return false;
|
||||
goto error;
|
||||
}
|
||||
|
||||
memcpy(info, buf + 12, 6);
|
||||
@ -55,7 +55,7 @@ bool rtga_image_load_shift(uint8_t *buf,
|
||||
if (!out_img->pixels)
|
||||
{
|
||||
fprintf(stderr, "Failed to allocate TGA pixels.\n");
|
||||
return false;
|
||||
goto error;
|
||||
}
|
||||
|
||||
tmp = buf + 18;
|
||||
@ -64,9 +64,7 @@ bool rtga_image_load_shift(uint8_t *buf,
|
||||
if (bits != 32 && bits != 24)
|
||||
{
|
||||
fprintf(stderr, "Bit depth of TGA image is wrong. Only 32-bit and 24-bit supported.\n");
|
||||
free(out_img->pixels);
|
||||
out_img->pixels = NULL;
|
||||
return false;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (bits == 32)
|
||||
@ -87,4 +85,12 @@ bool rtga_image_load_shift(uint8_t *buf,
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (out_img->pixels)
|
||||
free(out_img->pixels);
|
||||
|
||||
out_img->pixels = NULL;
|
||||
out_img->width = out_img->height = 0;
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user