comparison 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
comparison
equal deleted inserted replaced
1378:dc0e13e7e1ae 1379:c0a74f199ecf
281 } 281 }
282 282
283 char *SDL_VideoDriverName(char *namebuf, int maxlen) 283 char *SDL_VideoDriverName(char *namebuf, int maxlen)
284 { 284 {
285 if ( current_video != NULL ) { 285 if ( current_video != NULL ) {
286 SDL_strncpy(namebuf, current_video->name, maxlen-1); 286 SDL_strlcpy(namebuf, current_video->name, maxlen);
287 namebuf[maxlen-1] = '\0';
288 return(namebuf); 287 return(namebuf);
289 } 288 }
290 return(NULL); 289 return(NULL);
291 } 290 }
292 291
1662 if ( video ) { 1661 if ( video ) {
1663 if ( title ) { 1662 if ( title ) {
1664 if ( video->wm_title ) { 1663 if ( video->wm_title ) {
1665 SDL_free(video->wm_title); 1664 SDL_free(video->wm_title);
1666 } 1665 }
1667 video->wm_title = (char *)SDL_malloc(SDL_strlen(title)+1); 1666 video->wm_title = SDL_strdup(title);
1668 if ( video->wm_title != NULL ) {
1669 SDL_strcpy(video->wm_title, title);
1670 }
1671 } 1667 }
1672 if ( icon ) { 1668 if ( icon ) {
1673 if ( video->wm_icon ) { 1669 if ( video->wm_icon ) {
1674 SDL_free(video->wm_icon); 1670 SDL_free(video->wm_icon);
1675 } 1671 }
1676 video->wm_icon = (char *)SDL_malloc(SDL_strlen(icon)+1); 1672 video->wm_icon = SDL_strdup(icon);
1677 if ( video->wm_icon != NULL ) {
1678 SDL_strcpy(video->wm_icon, icon);
1679 }
1680 } 1673 }
1681 if ( (title || icon) && (video->SetCaption != NULL) ) { 1674 if ( (title || icon) && (video->SetCaption != NULL) ) {
1682 video->SetCaption(this, video->wm_title,video->wm_icon); 1675 video->SetCaption(this, video->wm_title,video->wm_icon);
1683 } 1676 }
1684 } 1677 }