Commit c21749e9 authored by Sam Lantinga's avatar Sam Lantinga

*** empty log message ***

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401576
parent 1b970c31
...@@ -109,16 +109,18 @@ static int CheckDrive(char *drive) ...@@ -109,16 +109,18 @@ static int CheckDrive(char *drive)
static void AddDrive(char *drive) static void AddDrive(char *drive)
{ {
int i; int i;
size_t len;
if ( SDL_numcds < MAX_DRIVES ) { if ( SDL_numcds < MAX_DRIVES ) {
/* Add this drive to our list */ /* Add this drive to our list */
i = SDL_numcds; i = SDL_numcds;
SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); len = SDL_strlen(drive)+1;
SDL_cdlist[i] = (char *)SDL_malloc(len);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
SDL_strcpy(SDL_cdlist[i], drive); SDL_strlcpy(SDL_cdlist[i], drive, len);
++SDL_numcds; ++SDL_numcds;
#ifdef CDROM_DEBUG #ifdef CDROM_DEBUG
fprintf(stderr, "Added CD-ROM drive: %s\n", drive); fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
...@@ -165,9 +167,10 @@ int SDL_SYS_CDInit(void) ...@@ -165,9 +167,10 @@ int SDL_SYS_CDInit(void)
SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
if ( SDLcdrom != NULL ) { if ( SDLcdrom != NULL ) {
char *cdpath, *delim; char *cdpath, *delim;
cdpath = (char *)SDL_malloc(SDL_strlen(SDLcdrom)+1); size_t len = SDL_strlen(SDLcdrom)+1;
cdpath = SDL_stack_alloc(char, len);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
SDL_strcpy(cdpath, SDLcdrom); SDL_strlcpy(cdpath, SDLcdrom, len);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = SDL_strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
...@@ -183,7 +186,7 @@ int SDL_SYS_CDInit(void) ...@@ -183,7 +186,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
SDL_free(cdpath); SDL_stack_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
......
...@@ -252,19 +252,20 @@ static void CustomApplicationMain (int argc, char **argv) ...@@ -252,19 +252,20 @@ static void CustomApplicationMain (int argc, char **argv)
return FALSE; return FALSE;
const char *temparg = [filename UTF8String]; const char *temparg = [filename UTF8String];
char *arg = (char *) malloc(strlen(temparg) + 1); size_t arglen = SDL_strlen(temparg) + 1;
char *arg = (char *) SDL_malloc(arglen);
if (arg == NULL) if (arg == NULL)
return FALSE; return FALSE;
char **newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2)); char **newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
if (newargv == NULL) if (newargv == NULL)
{ {
free(arg); SDL_free(arg);
return FALSE; return FALSE;
} }
gArgv = newargv; gArgv = newargv;
strcpy(arg, temparg); SDL_strlcpy(arg, temparg, arglen);
gArgv[gArgc++] = arg; gArgv[gArgc++] = arg;
gArgv[gArgc] = NULL; gArgv[gArgc] = NULL;
return TRUE; return TRUE;
...@@ -346,7 +347,7 @@ int main (int argc, char **argv) ...@@ -346,7 +347,7 @@ int main (int argc, char **argv)
/* Copy the arguments into a global variable */ /* Copy the arguments into a global variable */
/* This is passed if we are launched by double-clicking */ /* This is passed if we are launched by double-clicking */
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) { if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
gArgv = (char **) malloc(sizeof (char *) * 2); gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
gArgv[0] = argv[0]; gArgv[0] = argv[0];
gArgv[1] = NULL; gArgv[1] = NULL;
gArgc = 1; gArgc = 1;
...@@ -354,7 +355,7 @@ int main (int argc, char **argv) ...@@ -354,7 +355,7 @@ int main (int argc, char **argv)
} else { } else {
int i; int i;
gArgc = argc; gArgc = argc;
gArgv = (char **) malloc(sizeof (char *) * (argc+1)); gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
for (i = 0; i <= argc; i++) for (i = 0; i <= argc; i++)
gArgv[i] = argv[i]; gArgv[i] = argv[i];
gFinderLaunch = NO; gFinderLaunch = NO;
......
...@@ -639,7 +639,7 @@ int BE_GL_LoadLibrary(_THIS, const char *path) ...@@ -639,7 +639,7 @@ int BE_GL_LoadLibrary(_THIS, const char *path)
if (get_image_symbol((image_id)cookie,"glBegin",B_SYMBOL_TYPE_ANY,&location) == B_OK) { if (get_image_symbol((image_id)cookie,"glBegin",B_SYMBOL_TYPE_ANY,&location) == B_OK) {
_this->gl_config.dll_handle = (void*)cookie; _this->gl_config.dll_handle = (void*)cookie;
_this->gl_config.driver_loaded = 1; _this->gl_config.driver_loaded = 1;
SDL_strncpy(_this->gl_config.driver_path, "libGL.so", sizeof(_this->gl_config.driver_path)-1); SDL_strlcpy(_this->gl_config.driver_path, "libGL.so", SDL_arraysize(_this->gl_config.driver_path));
} }
} }
} }
...@@ -667,7 +667,7 @@ int BE_GL_LoadLibrary(_THIS, const char *path) ...@@ -667,7 +667,7 @@ int BE_GL_LoadLibrary(_THIS, const char *path)
if ((_this->gl_config.dll_handle = (void*)load_add_on(path)) != (void*)B_ERROR) { if ((_this->gl_config.dll_handle = (void*)load_add_on(path)) != (void*)B_ERROR) {
_this->gl_config.driver_loaded = 1; _this->gl_config.driver_loaded = 1;
SDL_strncpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path)-1); SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path));
}*/ }*/
} }
...@@ -676,7 +676,7 @@ int BE_GL_LoadLibrary(_THIS, const char *path) ...@@ -676,7 +676,7 @@ int BE_GL_LoadLibrary(_THIS, const char *path)
} else { } else {
_this->gl_config.dll_handle = NULL; _this->gl_config.dll_handle = NULL;
_this->gl_config.driver_loaded = 0; _this->gl_config.driver_loaded = 0;
SDL_strcpy(_this->gl_config.driver_path, ""); *_this->gl_config.driver_path = '\0';
return -1; return -1;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment