From: divverent Date: Wed, 4 Mar 2015 17:30:20 +0000 (+0000) Subject: Fix clang-analyzer false positives. X-Git-Tag: xonotic-v0.8.1~8^2~16 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=31f07ec3818f4ece09327401019d137140a3bae4;p=xonotic%2Fdarkplaces.git Fix clang-analyzer false positives. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12187 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_screen.c b/cl_screen.c index 7e15123c..66c17e17 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -1957,10 +1957,12 @@ void SHOWLMP_decodeshow(void) showlmp_t *oldshowlmps = cl.showlmps; cl.max_showlmps += 16; cl.showlmps = (showlmp_t *) Mem_Alloc(cls.levelmempool, cl.max_showlmps * sizeof(showlmp_t)); - if (cl.num_showlmps) - memcpy(cl.showlmps, oldshowlmps, cl.num_showlmps * sizeof(showlmp_t)); if (oldshowlmps) + { + if (cl.num_showlmps) + memcpy(cl.showlmps, oldshowlmps, cl.num_showlmps * sizeof(showlmp_t)); Mem_Free(oldshowlmps); + } } for (k = 0;k < cl.max_showlmps;k++) if (cl.showlmps[k].isactive && !strcmp(cl.showlmps[k].label, lmplabel)) diff --git a/model_shared.c b/model_shared.c index ec6a94ab..c1bd882f 100644 --- a/model_shared.c +++ b/model_shared.c @@ -1578,7 +1578,7 @@ static void Q3Shader_AddToHash (q3shaderinfo_t* shader) unsigned short hash = CRC_Block_CaseInsensitive ((const unsigned char *)shader->name, strlen (shader->name)); q3shader_hash_entry_t* entry = q3shader_data->hash + (hash % Q3SHADER_HASH_SIZE); q3shader_hash_entry_t* lastEntry = NULL; - while (entry != NULL) + do { if (strcasecmp (entry->shader.name, shader->name) == 0) { @@ -1611,6 +1611,7 @@ static void Q3Shader_AddToHash (q3shaderinfo_t* shader) lastEntry = entry; entry = entry->chain; } + while (entry != NULL); if (entry == NULL) { if (lastEntry->shader.name[0] != 0) diff --git a/prvm_edict.c b/prvm_edict.c index 31557d21..bc6c5ad5 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -3087,10 +3087,12 @@ int PRVM_SetTempString(prvm_prog_t *prog, const char *s) { Con_DPrintf("PRVM_SetTempString: enlarging tempstrings buffer (%iKB -> %iKB)\n", old.maxsize/1024, prog->tempstringsbuf.maxsize/1024); prog->tempstringsbuf.data = (unsigned char *) Mem_Alloc(prog->progs_mempool, prog->tempstringsbuf.maxsize); - if (old.cursize) - memcpy(prog->tempstringsbuf.data, old.data, old.cursize); if (old.data) + { + if (old.cursize) + memcpy(prog->tempstringsbuf.data, old.data, old.cursize); Mem_Free(old.data); + } } } t = (char *)prog->tempstringsbuf.data + prog->tempstringsbuf.cursize;