diff src/stdlib/SDL_getenv.c @ 1379:c0a74f199ecf

Use only safe string functions
author Sam Lantinga <slouken@libsdl.org>
date Sun, 19 Feb 2006 23:46:34 +0000
parents c71e05b4dc2e
children d910939febfa
line wrap: on
line diff
--- a/src/stdlib/SDL_getenv.c	Sun Feb 19 23:38:57 2006 +0000
+++ b/src/stdlib/SDL_getenv.c	Sun Feb 19 23:46:34 2006 +0000
@@ -53,7 +53,7 @@
 		SDL_envmem = newmem;
 		SDL_envmemlen = bufferlen;
 	}
-	SDL_strcpy(SDL_envmem, variable);
+	SDL_strlcpy(SDL_envmem, variable, bufferlen);
 	value = SDL_envmem + (sep - variable);
 	*value++ = '\0';
 	if ( !SetEnvironmentVariable(SDL_envmem, *value ? value : NULL) ) {
@@ -111,11 +111,10 @@
 	}
 
 	/* Allocate memory for the variable */
-	new_variable = (char *)SDL_malloc(SDL_strlen(variable)+1);
+	new_variable = SDL_strdup(variable);
 	if ( ! new_variable ) {
 		return(-1);
 	}
-	SDL_strcpy(new_variable, variable);
 
 	/* Actually put it into the environment */
 	added = 0;