Ryujinx-SDL/visualtest/src/mischelper.c
Philipp Wiesemann 0e45984fa0 Fixed crash if initialization of EGL failed but was tried again later.
The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly
uninitialized data structure if loading the library first failed. A later try to
use EGL then skipped initialization and assumed it was previously successful
because the data structure now already existed. This led to at least one crash
in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was
dereferenced to make a call to eglBindAPI().
2015-06-21 17:33:46 +02:00

28 lines
613 B
C

/**
* \file mischelper.c
*
* Source file with miscellaneous helper functions.
*/
#include <SDL_test.h>
void
SDLVisualTest_HashString(char* str, char hash[33])
{
SDLTest_Md5Context md5c;
int i;
if(!str)
{
SDLTest_LogError("str argument cannot be NULL");
return;
}
SDLTest_Md5Init(&md5c);
SDLTest_Md5Update(&md5c, (unsigned char*)str, SDL_strlen(str));
SDLTest_Md5Final(&md5c);
/* convert the md5 hash to an array of hexadecimal digits */
for(i = 0; i < 16; i++)
SDL_snprintf(hash + 2 * i, 33 - 2 * i, "%02x", (int)md5c.digest[i]);
}