src/SDL_error.c
changeset 1379 c0a74f199ecf
parent 1361 19418e4422cb
child 1402 d910939febfa
     1.1 --- a/src/SDL_error.c	Sun Feb 19 23:38:57 2006 +0000
     1.2 +++ b/src/SDL_error.c	Sun Feb 19 23:46:34 2006 +0000
     1.3 @@ -59,8 +59,7 @@
     1.4  	/* Copy in the key, mark error as valid */
     1.5  	error = SDL_GetErrBuf();
     1.6  	error->error = 1;
     1.7 -	SDL_strncpy((char *)error->key, fmt, sizeof(error->key));
     1.8 -	error->key[sizeof(error->key)-1] = '\0';
     1.9 +	SDL_strlcpy((char *)error->key, fmt, sizeof(error->key));
    1.10  
    1.11  	va_start(ap, fmt);
    1.12  	error->argc = 0;
    1.13 @@ -94,8 +93,7 @@
    1.14  				  char *str = va_arg(ap, char *);
    1.15  				  if (str == NULL)
    1.16  				      str = "(null)";
    1.17 -				  SDL_strncpy((char *)error->args[index].buf, str, ERR_MAX_STRLEN);
    1.18 -				  error->args[index].buf[ERR_MAX_STRLEN-1] = 0;
    1.19 +				  SDL_strlcpy((char *)error->args[index].buf, str, ERR_MAX_STRLEN);
    1.20  				  error->argc++;
    1.21  				}
    1.22  				break;
    1.23 @@ -251,8 +249,7 @@
    1.24  	/* Allocate the UNICODE buffer */
    1.25  	errstr16 = (Uint16 *)SDL_malloc(maxlen * (sizeof *errstr16));
    1.26  	if ( ! errstr16 ) {
    1.27 -		SDL_strncpy((char *)errstr, "Out of memory", maxlen);
    1.28 -		errstr[maxlen-1] = '\0';
    1.29 +		SDL_strlcpy((char *)errstr, "Out of memory", maxlen);
    1.30  		return(errstr);
    1.31  	}
    1.32