Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/client/cl_cgame.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
Com_Memcpy( VMA(1), VMA(2), args[3] );
return 0;
case CG_STRNCPY:
strncpy( VMA(1), VMA(2), args[3] );
Q_strncpy( VMA(1), VMA(2), args[3] );
return args[1];
case CG_SIN:
return FloatAsInt( sin( VMF(1) ) );
Expand Down
21 changes: 20 additions & 1 deletion code/qcommon/q_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,25 @@ int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap)
}
#endif

/*
Copied from code/game/bg_lib.c
It is here to avoid undifined behavior when source and destination overlap.
This is used quite a lot in the code.
*/
char *Q_strncpy(char *strDest, const char *strSource, size_t count) {
char *s;

s = strDest;
while (*strSource && count) {
*s++ = *strSource++;
count--;
}
while (count--) {
*s++ = 0;
}
return strDest;
}

/*
=============
Q_strncpyz
Expand All @@ -807,7 +826,7 @@ void Q_strncpyz( char *dest, const char *src, int destsize ) {
Com_Error(ERR_FATAL,"Q_strncpyz: destsize < 1" );
}

strncpy( dest, src, destsize-1 );
Q_strncpy( dest, src, destsize-1 );
dest[destsize-1] = 0;
}

Expand Down
1 change: 1 addition & 0 deletions code/qcommon/q_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ char *Q_strupr( char *s1 );
const char *Q_stristr( const char *s, const char *find);

// buffer size safe library replacements
char *Q_strncpy(char *strDest, const char *strSource, size_t count);
void Q_strncpyz( char *dest, const char *src, int destsize );
void Q_strcat( char *dest, int size, const char *src );

Expand Down
6 changes: 0 additions & 6 deletions code/sdl/sdl_glimp.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,12 +630,6 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
vresWidth = glConfig.vidWidth;
vresHeight = glConfig.vidHeight;




vresWidth = 640;
vresHeight = 480;

#if SDL_MAJOR_VERSION != 2
screen = vidscreen;
#endif
Expand Down
Loading