diff src/video/SDL_video.c @ 1379:c0a74f199ecf

Use only safe string functions
author Sam Lantinga <slouken@libsdl.org>
date Sun, 19 Feb 2006 23:46:34 +0000
parents 19418e4422cb
children 85d8b5fdd9f6
line wrap: on
line diff
--- a/src/video/SDL_video.c	Sun Feb 19 23:38:57 2006 +0000
+++ b/src/video/SDL_video.c	Sun Feb 19 23:46:34 2006 +0000
@@ -283,8 +283,7 @@
 char *SDL_VideoDriverName(char *namebuf, int maxlen)
 {
 	if ( current_video != NULL ) {
-		SDL_strncpy(namebuf, current_video->name, maxlen-1);
-		namebuf[maxlen-1] = '\0';
+		SDL_strlcpy(namebuf, current_video->name, maxlen);
 		return(namebuf);
 	}
 	return(NULL);
@@ -1664,19 +1663,13 @@
 			if ( video->wm_title ) {
 				SDL_free(video->wm_title);
 			}
-			video->wm_title = (char *)SDL_malloc(SDL_strlen(title)+1);
-			if ( video->wm_title != NULL ) {
-				SDL_strcpy(video->wm_title, title);
-			}
+			video->wm_title = SDL_strdup(title);
 		}
 		if ( icon ) {
 			if ( video->wm_icon ) {
 				SDL_free(video->wm_icon);
 			}
-			video->wm_icon = (char *)SDL_malloc(SDL_strlen(icon)+1);
-			if ( video->wm_icon != NULL ) {
-				SDL_strcpy(video->wm_icon, icon);
-			}
+			video->wm_icon = SDL_strdup(icon);
 		}
 		if ( (title || icon) && (video->SetCaption != NULL) ) {
 			video->SetCaption(this, video->wm_title,video->wm_icon);