1
0
Fork 0
forked from fte/fteqw

fix some memory reference/leak errors reported by valgrind.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5222 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2018-03-06 16:46:57 +00:00
parent aa18ab9c01
commit 4a29919111
8 changed files with 40 additions and 10 deletions

View file

@ -39,6 +39,7 @@ static void *alsasharedobject;
int (*psnd_pcm_open) (snd_pcm_t **pcm, const char *name, snd_pcm_stream_t stream, int mode);
int (*psnd_pcm_close) (snd_pcm_t *pcm);
int (*psnd_config_update_free_global)(void);
const char *(*psnd_strerror) (int errnum);
int (*psnd_pcm_hw_params_any) (snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
int (*psnd_pcm_hw_params_set_access) (snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t _access);
@ -179,6 +180,7 @@ static void ALSA_RW_Submit (soundcardinfo_t *sc, int start, int end)
static void ALSA_Shutdown (soundcardinfo_t *sc)
{
psnd_pcm_close (sc->handle);
psnd_config_update_free_global(); //and try to reduce leaks
if (sc->Submit == ALSA_RW_Submit)
free(sc->sn.buffer);
@ -217,6 +219,7 @@ static qboolean Alsa_InitAlsa(void)
psnd_pcm_open = dlsym(alsasharedobject, "snd_pcm_open");
psnd_pcm_close = dlsym(alsasharedobject, "snd_pcm_close");
psnd_config_update_free_global = dlsym(alsasharedobject, "snd_config_update_free_global");
psnd_strerror = dlsym(alsasharedobject, "snd_strerror");
psnd_pcm_hw_params_any = dlsym(alsasharedobject, "snd_pcm_hw_params_any");
psnd_pcm_hw_params_set_access = dlsym(alsasharedobject, "snd_pcm_hw_params_set_access");
@ -251,6 +254,7 @@ static qboolean Alsa_InitAlsa(void)
alsaworks = psnd_pcm_open
&& psnd_pcm_close
&& psnd_config_update_free_global
&& psnd_strerror
&& psnd_pcm_hw_params_any
&& psnd_pcm_hw_params_set_access

View file

@ -2975,6 +2975,9 @@ void Mod_LoadAliasShaders(model_t *mod)
if (r_loadbumpmapping)
loadflags |= SHADER_HASNORMALMAP;
mipdata[0] = f->texels;
mipdata[1] = NULL;
mipdata[2] = NULL;
mipdata[3] = NULL;
R_BuildLegacyTexnums(f->shader, basename, alttexpath, loadflags, imageflags, skintranstype, s->skinwidth, s->skinheight, mipdata, host_basepal);
}
else

View file

@ -93,17 +93,15 @@ anyway, the actual interface is the same. the old version might be slower, but w
#endif
/*end glibc workaround*/
#define NUM_SAFE_ARGVS 6
usercmd_t nullcmd; // guarenteed to be zero
entity_state_t nullentitystate; //this is the default state
static const char *largv[MAX_NUM_ARGVS + NUM_SAFE_ARGVS + 1];
static char *argvdummy = " ";
static char *safeargvs[] =
{"-stdvid", "-nolan", "-nosound", "-nocdaudio", "-nojoy", "-nomouse", "-nohome", "-window"};
static char *safeargvs[NUM_SAFE_ARGVS] =
{"-stdvid", "-nolan", "-nosound", "-nocdaudio", "-nojoy", "-nomouse"};
static const char *largv[MAX_NUM_ARGVS + countof(safeargvs) + 1];
static char *argvdummy = " ";
cvar_t registered = CVARD("registered","0","Set if quake's pak1.pak is available");
cvar_t gameversion = CVARFD("gameversion","", CVAR_SERVERINFO, "gamecode version for server browsers");
@ -4709,7 +4707,7 @@ void COM_InitArgv (int argc, const char **argv) //not allowed to tprint
{
// force all the safe-mode switches. Note that we reserved extra space in
// case we need to add these, so we don't need an overflow check
for (i=0 ; i<NUM_SAFE_ARGVS ; i++)
for (i=0 ; i<countof(safeargvs) ; i++)
{
largv[com_argc] = safeargvs[i];
com_argc++;

View file

@ -149,6 +149,7 @@ static int (VARGS *qgnutls_error_is_fatal)(int error);
static int (VARGS *qgnutls_credentials_set)(gnutls_session_t, gnutls_credentials_type_t type, void* cred);
//static int (VARGS *qgnutls_kx_set_priority)(gnutls_session_t session, const int*);
static int (VARGS *qgnutls_init)(gnutls_session_t * session, gnutls_connection_end_t con_end);
static void (VARGS *qgnutls_deinit)(gnutls_session_t session);
static int (VARGS *qgnutls_set_default_priority)(gnutls_session_t session);
static int (VARGS *qgnutls_certificate_allocate_credentials)(gnutls_certificate_credentials_t *sc);
static int (VARGS *qgnutls_anon_allocate_client_credentials)(gnutls_anon_client_credentials_t *sc);
@ -279,6 +280,7 @@ static qboolean Init_GNUTLS(void)
GNUTLS_FUNC(gnutls_error_is_fatal) \
GNUTLS_FUNC(gnutls_credentials_set) \
GNUTLS_FUNC(gnutls_init) \
GNUTLS_FUNC(gnutls_deinit) \
GNUTLS_FUNC(gnutls_set_default_priority) \
GNUTLS_FUNC(gnutls_certificate_allocate_credentials) \
GNUTLS_FUNC(gnutls_anon_allocate_client_credentials) \
@ -316,6 +318,7 @@ static qboolean Init_GNUTLS(void)
{(void**)&qgnutls_credentials_set, "gnutls_credentials_set"},
// {(void**)&qgnutls_kx_set_priority, "gnutls_kx_set_priority"},
{(void**)&qgnutls_init, "gnutls_init"},
{(void**)&qgnutls_deinit, "gnutls_deinit"},
{(void**)&qgnutls_set_default_priority, "gnutls_set_default_priority"},
{(void**)&qgnutls_certificate_allocate_credentials, "gnutls_certificate_allocate_credentials"},
{(void**)&qgnutls_anon_allocate_client_credentials, "gnutls_anon_allocate_client_credentials"},
@ -431,11 +434,15 @@ static qboolean QDECL SSL_Close(vfsfile_t *vfs)
file->handshaking = true;
if (file->session)
{
qgnutls_bye (file->session, file->datagram?GNUTLS_SHUT_WR:GNUTLS_SHUT_RDWR);
qgnutls_deinit(file->session);
}
file->session = NULL;
if (file->stream)
VFS_CLOSE(file->stream);
file->stream = NULL;
Z_Free(file);
return true;
}
@ -952,10 +959,14 @@ qboolean SSL_InitGlobal(qboolean isserver)
{
static int initstatus[2];
isserver = !!isserver;
if (COM_CheckParm("-notls"))
return false;
Sys_LockMutex(com_resourcemutex);
if (!initstatus[isserver])
{
if (!Init_GNUTLS())
{
Sys_UnlockMutex(com_resourcemutex);
Con_Printf("GnuTLS "GNUTLS_VERSION" library not available.\n");
return false;
}
@ -980,6 +991,7 @@ qboolean SSL_InitGlobal(qboolean isserver)
qgnutls_certificate_set_x509_trust_file (xcred[isserver], CAFILE, GNUTLS_X509_FMT_PEM);
#endif
Sys_UnlockMutex(com_resourcemutex);
if (isserver)
{
#if 1
@ -1004,6 +1016,8 @@ qboolean SSL_InitGlobal(qboolean isserver)
qgnutls_certificate_set_verify_function (xcred[isserver], SSL_CheckCert);
#endif
}
else
Sys_UnlockMutex(com_resourcemutex);
if (initstatus[isserver] < 0)
return false;

View file

@ -2192,6 +2192,7 @@ struct font_s *Font_LoadFont(float vheight, const char *fontfilename)
//removes a font from memory.
void Font_Free(struct font_s *f)
{
size_t i;
struct charcache_s **link, *c, *valid;
//kill the alt font first.
@ -2237,6 +2238,10 @@ void Font_Free(struct font_s *f)
Z_Free(qface);
}
}
for (i = 0; i < FONTBLOCKS; i++)
if (f->chars[i])
Z_Free(f->chars[i]);
Z_Free(f);
}

View file

@ -5642,11 +5642,11 @@ void QDECL R_BuildLegacyTexnums(shader_t *shader, const char *fallbackname, cons
case TF_MIP4_SOLID8:
case TF_SOLID8:
imageflags |= IF_NOALPHA;
if (!mipdata[0] || !mipdata[1] || !mipdata[2] || !mipdata[3])
if (!mipdata || !mipdata[0] || !mipdata[1] || !mipdata[2] || !mipdata[3])
basefmt = TF_SOLID8;
break;
default:
if (!mipdata[0] || !mipdata[1] || !mipdata[2] || !mipdata[3])
if (!mipdata || !mipdata[0] || !mipdata[1] || !mipdata[2] || !mipdata[3])
basefmt = TF_SOLID8;
break;
}

View file

@ -3194,9 +3194,13 @@ qboolean X11VID_Init (rendererstate_t *info, unsigned char *palette, int psl)
case PSL_GLX:
if (!GLX_Init(info, fbconfig, visinfo))
{
if (visinfo != &vinfodef)
x11.pXFree(visinfo);
GLVID_Shutdown();
return false;
}
if (visinfo != &vinfodef)
x11.pXFree(visinfo);
break;
#ifdef USE_EGL
case PSL_EGL:
@ -3441,7 +3445,7 @@ void INS_EnumerateDevices(void *ctx, void(*callback)(void *ctx, const char *type
for (i = 0; i < devs; i++)
{
if (!dev[i].enabled)
return;
continue;
if (/*dev[i].use == XIMasterPointer ||*/ dev[i].use == XISlavePointer)
{
struct xidevinfo *devi = XI2_GetDeviceInfo(dev[i].deviceid);

View file

@ -746,6 +746,8 @@ eval_t *PDECL PR_FindGlobal(pubprogfuncs_t *ppf, const char *globname, progsnum_
unsigned int i;
ddef16_t *var16;
ddef32_t *var32;
if (type)
*type = ev_void;
if (pnum == PR_CURRENT)
pnum = prinst.pr_typecurrent;
if (pnum == PR_ANY)