From 828cafbc1ff81df5a01d45f529769bde8e45e1bf Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 2 Jul 2002 04:07:01 +0000 Subject: [PATCH] Bugfix from Corona688: don't reference a string before we've initialized it. Fixes crashbug on WinCE (PocketPC). --- src/video/windib/SDL_dibevents.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/video/windib/SDL_dibevents.c b/src/video/windib/SDL_dibevents.c index ff8ef64f1..26eb31da0 100644 --- a/src/video/windib/SDL_dibevents.c +++ b/src/video/windib/SDL_dibevents.c @@ -335,11 +335,18 @@ int DIB_CreateWindow(_THIS) { #ifdef _WIN32_WCE /* WinCE uses the UNICODE version */ - int nLen = strlen(SDL_Appname)+1; - LPWSTR lpszW = alloca(nLen*2); - MultiByteToWideChar(CP_ACP, 0, SDL_Appname, -1, lpszW, nLen); + int nLen; + LPWSTR lpszW; + + if ( SDL_RegisterApp("SDL_app", 0, 0) != 0 ) { + return -1; + } + + nLen = strlen(SDL_Appname) + 1; + lpszW = alloca(nLen * 2); + + MultiByteToWideChar(CP_ACP, 0, "SDL_App", -1, lpszW, nLen); - SDL_RegisterApp("SDL_app", 0, 0); SDL_Window = CreateWindow(lpszW, lpszW, WS_VISIBLE, 0, 0, 0, 0, NULL, NULL, SDL_Instance, NULL); if ( SDL_Window == NULL ) {