#592:fixed crash

This commit is contained in:
Vadim Grigoruk 2018-08-03 10:48:15 +03:00
parent b14dd23f5d
commit 5e90d56635
1 changed files with 6 additions and 5 deletions

View File

@ -48,7 +48,7 @@ static void onExit(void* data)
run->exit = true; run->exit = true;
} }
static char* data2md5(const void* data, s32 length) static const char* data2md5(const void* data, s32 length)
{ {
const char *str = data; const char *str = data;
MD5_CTX c; MD5_CTX c;
@ -66,11 +66,12 @@ static char* data2md5(const void* data, s32 length)
} }
{ {
u8 digest[16]; enum{Size = 16};
u8 digest[Size];
MD5_Final(digest, &c); MD5_Final(digest, &c);
for (s32 n = 0; n < 16; ++n) for (s32 n = 0; n < Size; ++n)
snprintf(&(out[n*2]), 16*2, "%02x", (u32)digest[n]); snprintf(out + n*2, sizeof("ff"), "%02x", digest[n]);
} }
return out; return out;
@ -79,7 +80,7 @@ static char* data2md5(const void* data, s32 length)
static void initPMemName(Run* run) static void initPMemName(Run* run)
{ {
const char* data = strlen(run->tic->saveid) ? run->tic->saveid : run->tic->cart.bank0.code.data; const char* data = strlen(run->tic->saveid) ? run->tic->saveid : run->tic->cart.bank0.code.data;
char* md5 = data2md5(data, (s32)strlen(data)); const char* md5 = data2md5(data, strlen(data));
strcpy(run->saveid, TIC_LOCAL); strcpy(run->saveid, TIC_LOCAL);
strcat(run->saveid, md5); strcat(run->saveid, md5);
} }