SDL_LoadObject (windows, os/2): prevent crash if dll name is NULL.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
diff --git a/src/loadso/os2/SDL_sysloadso.c b/src/loadso/os2/SDL_sysloadso.c
index c443393..ca9d2fd 100644
--- a/src/loadso/os2/SDL_sysloadso.c
+++ b/src/loadso/os2/SDL_sysloadso.c
@@ -37,9 +37,15 @@ SDL_LoadObject(const char *sofile)
{
ULONG ulRC;
HMODULE hModule;
- PSZ pszModName = OS2_UTF8ToSys(sofile);
CHAR acError[256];
+ PSZ pszModName;
+ if (!sofile) {
+ SDL_SetError("NULL sofile");
+ return NULL;
+ }
+
+ pszModName = OS2_UTF8ToSys(sofile);
ulRC = DosLoadModule(acError, sizeof(acError), pszModName, &hModule);
SDL_free(pszModName);
if (ulRC != NO_ERROR) {
diff --git a/src/loadso/windows/SDL_sysloadso.c b/src/loadso/windows/SDL_sysloadso.c
index 99e8360..a5e9852 100644
--- a/src/loadso/windows/SDL_sysloadso.c
+++ b/src/loadso/windows/SDL_sysloadso.c
@@ -32,7 +32,15 @@
void *
SDL_LoadObject(const char *sofile)
{
- LPTSTR tstr = WIN_UTF8ToString(sofile);
+ LPTSTR tstr;
+
+ if (!sofile) {
+ SDL_SetError("NULL sofile");
+ return NULL;
+ }
+
+ tstr = WIN_UTF8ToString(sofile);
+
#ifdef __WINRT__
/* WinRT only publically supports LoadPackagedLibrary() for loading .dll
files. LoadLibrary() is a private API, and not available for apps