From 677d757c181e0dfd8ef4005e01de8a4f497c551c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Oct 2015 18:00:22 +0200 Subject: [PATCH] backport 'add guard for unknown roms with 8MB or more' --- cheevos.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cheevos.c b/cheevos.c index 53da6c4761..96bbbb84a3 100644 --- a/cheevos.c +++ b/cheevos.c @@ -1301,13 +1301,13 @@ int cheevos_get_by_content( const char** json, const void* data, size_t size ) game_id = cheevos_get_game_id( hash ); - if ( !game_id ) + if ( !game_id && size < CHEEVOS_EIGHT_MB ) { - /* If the content is a SNES game, continue MD5 with zeroes. */ + /* Maybe the content is a SNES game, continue MD5 with zeroes up to 8MB. */ size = CHEEVOS_EIGHT_MB - size; memset( (void*)buffer, 0, sizeof( buffer ) ); - while ( size ) + do { len = sizeof( buffer ); @@ -1316,7 +1316,7 @@ int cheevos_get_by_content( const char** json, const void* data, size_t size ) MD5_Update( &saved_ctx, (void*)buffer, len ); size -= len; - } + }while(size); MD5_Final( hash, &saved_ctx );