src/stdlib/SDL_getenv.c
changeset 1379 c0a74f199ecf
parent 1358 c71e05b4dc2e
child 1402 d910939febfa
--- 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;