Add patch 1239754 from Moe. This patches fixes a few crashes by checking the SDL_SetMode return value and it changes strncopy to a safe_strncopy which adds a 0 to each string copied
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2240
This commit is contained in:
parent
3429a18dc4
commit
c7c2ee5d5a
14 changed files with 56 additions and 41 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: midi_alsa.h,v 1.11 2005-02-10 10:20:52 qbix79 Exp $ */
|
||||
/* $Id: midi_alsa.h,v 1.12 2005-07-19 19:45:31 qbix79 Exp $ */
|
||||
|
||||
#define ALSA_PCM_OLD_HW_PARAMS_API
|
||||
#define ALSA_PCM_OLD_SW_PARAMS_API
|
||||
|
@ -129,7 +129,7 @@ public:
|
|||
|
||||
// try to use port specified in config file
|
||||
if (conf && conf[0]) {
|
||||
strncpy(var, conf, 10);
|
||||
safe_strncpy(var, conf, 10);
|
||||
if (parse_addr(var, &seq_client, &seq_port) < 0) {
|
||||
LOG_MSG("ALSA:Invalid alsa port %s", var);
|
||||
return false;
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
char * GetName(void) { return "oss";};
|
||||
bool Open(const char * conf) {
|
||||
char devname[512];
|
||||
if (conf && conf[0]) strncpy(devname,conf,512);
|
||||
if (conf && conf[0]) safe_strncpy(devname,conf,512);
|
||||
else strcpy(devname,"/dev/sequencer");
|
||||
char * devfind=(strrchr(devname,','));
|
||||
if (devfind) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: sdl_mapper.cpp,v 1.12 2005-06-13 14:48:02 qbix79 Exp $ */
|
||||
/* $Id: sdl_mapper.cpp,v 1.13 2005-07-19 19:45:31 qbix79 Exp $ */
|
||||
|
||||
#define OLD_JOYSTICK 1
|
||||
|
||||
|
@ -95,7 +95,7 @@ static CBindList holdlist;
|
|||
class CEvent {
|
||||
public:
|
||||
CEvent(char * _entry) {
|
||||
strncpy(entry,_entry,16);
|
||||
safe_strncpy(entry,_entry,16);
|
||||
events.push_back(this);
|
||||
bindlist.clear();
|
||||
activity=0;
|
||||
|
@ -1444,6 +1444,7 @@ void MAPPER_Run(void) {
|
|||
/* Be sure that there is no update in progress */
|
||||
GFX_EndUpdate();
|
||||
mapper.surface=SDL_SetVideoMode(640,480,8,0);
|
||||
if (mapper.surface == NULL) E_Exit("Could not initialize video mode for mapper: %s",SDL_GetError());
|
||||
|
||||
/* Set some palette entries */
|
||||
SDL_SetPalette(mapper.surface, SDL_LOGPAL|SDL_PHYSPAL, map_pal, 0, 4);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: sdlmain.cpp,v 1.85 2005-05-18 21:59:58 qbix79 Exp $ */
|
||||
/* $Id: sdlmain.cpp,v 1.86 2005-07-19 19:45:32 qbix79 Exp $ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
|
@ -316,18 +316,24 @@ static SDL_Surface * GFX_SetupSurfaceScaled(Bit32u sdl_flags,Bit32u bpp) {
|
|||
}
|
||||
sdl.clip.x=(Sint16)((sdl.desktop.width-sdl.clip.w)/2);
|
||||
sdl.clip.y=(Sint16)((sdl.desktop.height-sdl.clip.h)/2);
|
||||
return sdl.surface=SDL_SetVideoMode(sdl.desktop.width,sdl.desktop.height,bpp,sdl_flags|SDL_FULLSCREEN|SDL_HWSURFACE);
|
||||
sdl.surface=SDL_SetVideoMode(sdl.desktop.width,sdl.desktop.height,bpp,sdl_flags|SDL_FULLSCREEN|SDL_HWSURFACE);
|
||||
if (sdl.surface == NULL) E_Exit("Could not set fullscreen video mode %ix%i-%i: %s",sdl.desktop.width,sdl.desktop.height,bpp,SDL_GetError());
|
||||
return sdl.surface;
|
||||
} else {
|
||||
sdl.clip.x=0;sdl.clip.y=0;
|
||||
sdl.clip.w=(Bit16u)(sdl.draw.width*sdl.draw.scalex);
|
||||
sdl.clip.h=(Bit16u)(sdl.draw.height*sdl.draw.scaley);
|
||||
return sdl.surface=SDL_SetVideoMode(sdl.clip.w,sdl.clip.h,bpp,sdl_flags|SDL_FULLSCREEN|SDL_HWSURFACE);
|
||||
sdl.surface=SDL_SetVideoMode(sdl.clip.w,sdl.clip.h,bpp,sdl_flags|SDL_FULLSCREEN|SDL_HWSURFACE);
|
||||
if (sdl.surface == NULL) E_Exit("Could not set fullscreen video mode %ix%i-%i: %s",sdl.clip.w,sdl.clip.h,bpp,SDL_GetError());
|
||||
return sdl.surface;
|
||||
}
|
||||
} else {
|
||||
sdl.clip.x=0;sdl.clip.y=0;
|
||||
sdl.clip.w=(Bit16u)(sdl.draw.width*sdl.draw.scalex*sdl.desktop.hwscale);
|
||||
sdl.clip.h=(Bit16u)(sdl.draw.height*sdl.draw.scaley*sdl.desktop.hwscale);
|
||||
return sdl.surface=SDL_SetVideoMode(sdl.clip.w,sdl.clip.h,bpp,sdl_flags|SDL_HWSURFACE);
|
||||
sdl.surface=SDL_SetVideoMode(sdl.clip.w,sdl.clip.h,bpp,sdl_flags|SDL_HWSURFACE);
|
||||
if (sdl.surface == NULL) E_Exit("Could not set windowed video mode %ix%i-%i: %s",sdl.clip.w,sdl.clip.h,bpp,SDL_GetError());
|
||||
return sdl.surface;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,14 +363,17 @@ dosurface:
|
|||
sdl.clip.y=(Sint16)((sdl.desktop.height-height)/2);
|
||||
sdl.surface=SDL_SetVideoMode(sdl.desktop.width,sdl.desktop.height,bpp,
|
||||
SDL_FULLSCREEN|SDL_HWSURFACE|(sdl.desktop.doublebuf ? SDL_DOUBLEBUF|SDL_ASYNCBLIT : 0)|SDL_HWPALETTE);
|
||||
if (sdl.surface == NULL) E_Exit("Could not set fullscreen video mode %ix%i-%i: %s",sdl.desktop.width,sdl.desktop.height,bpp,SDL_GetError());
|
||||
} else {
|
||||
sdl.clip.x=0;sdl.clip.y=0;
|
||||
sdl.surface=SDL_SetVideoMode(width,height,bpp,
|
||||
SDL_FULLSCREEN|SDL_HWSURFACE|(sdl.desktop.doublebuf ? SDL_DOUBLEBUF|SDL_ASYNCBLIT : 0)|SDL_HWPALETTE);
|
||||
if (sdl.surface == NULL) E_Exit("Could not set fullscreen video mode %ix%i-%i: %s",width,height,bpp,SDL_GetError());
|
||||
}
|
||||
} else {
|
||||
sdl.clip.x=0;sdl.clip.y=0;
|
||||
sdl.surface=SDL_SetVideoMode(width,height,bpp,SDL_HWSURFACE);
|
||||
if (sdl.surface == NULL) E_Exit("Could not set windowed video mode %ix%i-%i: %s",width,height,bpp,SDL_GetError());
|
||||
}
|
||||
if (sdl.surface) switch (sdl.surface->format->BitsPerPixel) {
|
||||
case 8:sdl.draw.mode=GFX_8;break;
|
||||
|
@ -857,6 +866,10 @@ static void GUI_StartUp(Section * sec) {
|
|||
#if C_OPENGL
|
||||
if(sdl.desktop.want_type==SCREEN_OPENGL){ /* OPENGL is requested */
|
||||
sdl.surface=SDL_SetVideoMode(640,400,0,SDL_OPENGL);
|
||||
if (sdl.surface == NULL) {
|
||||
LOG_MSG("Could not initialize OpenGL, switching back to surface");
|
||||
sdl.desktop.want_type=SCREEN_SURFACE;
|
||||
} else {
|
||||
sdl.opengl.framebuf=0;
|
||||
sdl.opengl.texture=0;
|
||||
sdl.opengl.displaylist=0;
|
||||
|
@ -877,11 +890,13 @@ static void GUI_StartUp(Section * sec) {
|
|||
} else {
|
||||
sdl.opengl.packed_pixel=sdl.opengl.paletted_texture=false;
|
||||
}
|
||||
}
|
||||
} /* OPENGL is requested end */
|
||||
|
||||
#endif //OPENGL
|
||||
/* Initialize screen for first time */
|
||||
sdl.surface=SDL_SetVideoMode(640,400,0,0);
|
||||
if (sdl.surface == NULL) E_Exit("Could not initialize video: %s",SDL_GetError());
|
||||
sdl.desktop.bpp=sdl.surface->format->BitsPerPixel;
|
||||
if (sdl.desktop.bpp==24) {
|
||||
LOG_MSG("SDL:You are running in 24 bpp mode, this will slow down things!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue