diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index 9d3fabe4d4..448b6e4b23 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -20,7 +20,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#ifdef DEBUG #include +#endif #include #include #include @@ -132,7 +134,6 @@ static INLINE uint32_t dword_be(const uint8_t *buf) static bool png_process_ihdr(struct png_ihdr *ihdr) { unsigned i; - bool ret = true; switch (ihdr->color_type) { @@ -140,7 +141,12 @@ static bool png_process_ihdr(struct png_ihdr *ihdr) case PNG_IHDR_COLOR_GRAY_ALPHA: case PNG_IHDR_COLOR_RGBA: if (ihdr->depth != 8 && ihdr->depth != 16) - GOTO_END_ERROR(); + { +#ifdef DEBUG + fprintf(stderr, "[RPNG]: Error in line %d.\n", __LINE__); +#endif + return false; + } break; case PNG_IHDR_COLOR_GRAY: { @@ -157,7 +163,12 @@ static bool png_process_ihdr(struct png_ihdr *ihdr) } if (!correct_bpp) - GOTO_END_ERROR(); + { +#ifdef DEBUG + fprintf(stderr, "[RPNG]: Error in line %d.\n", __LINE__); +#endif + return false; + } } break; case PNG_IHDR_COLOR_PLT: @@ -175,11 +186,19 @@ static bool png_process_ihdr(struct png_ihdr *ihdr) } if (!correct_bpp) - GOTO_END_ERROR(); + { +#ifdef DEBUG + fprintf(stderr, "[RPNG]: Error in line %d.\n", __LINE__); +#endif + return false; + } } break; default: - GOTO_END_ERROR(); +#ifdef DEBUG + fprintf(stderr, "[RPNG]: Error in line %d.\n", __LINE__); +#endif + return false; } #ifdef RPNG_TEST @@ -192,10 +211,14 @@ static bool png_process_ihdr(struct png_ihdr *ihdr) #endif if (ihdr->compression != 0) - GOTO_END_ERROR(); + { +#ifdef DEBUG + fprintf(stderr, "[RPNG]: Error in line %d.\n", __LINE__); +#endif + return false; + } -end: - return ret; + return true; } static void png_reverse_filter_copy_line_rgb(uint32_t *data, diff --git a/libretro-common/formats/png/rpng_internal.h b/libretro-common/formats/png/rpng_internal.h index 3e4dcc990f..9e5d78f801 100644 --- a/libretro-common/formats/png/rpng_internal.h +++ b/libretro-common/formats/png/rpng_internal.h @@ -27,13 +27,6 @@ #include #include -#undef GOTO_END_ERROR -#define GOTO_END_ERROR() do { \ - fprintf(stderr, "[RPNG]: Error in line %d.\n", __LINE__); \ - ret = false; \ - goto end; \ -} while (0) - #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) #endif