- round #2 of coverity bug fixes

This commit is contained in:
SoftCoder
2013-12-14 22:37:15 -08:00
parent b8ab732b85
commit f269273f07
25 changed files with 195 additions and 152 deletions

View File

@@ -130,7 +130,7 @@ int g3d2xml(FILE *infile, FILE *outfile)
struct ModelHeader modelHeader;
struct MeshHeader meshHeader;
size_t nBytes;
uint8 textureName[NAMESIZE];
uint8 textureName[NAMESIZE+1];
float32 *fdata;
uint32 *idata;
unsigned int ii, jj, kk;
@@ -226,7 +226,8 @@ int g3d2xml(FILE *infile, FILE *outfile)
/* read / write the texture name if present */
if (meshHeader.textures)
{
nBytes = sizeof(textureName);
memset(&textureName[0],0,NAMESIZE+1);
nBytes = NAMESIZE;
if (fread(&textureName, nBytes, 1, infile) != 1)
{
printf("Could not read texture name!\n");

View File

@@ -245,7 +245,7 @@ int processMesh(xmlNode *n, FILE *outfile)
float32 color[3];
struct MeshHeader mh;
uint8 texname[NAMESIZE];
uint8 texname[NAMESIZE+1];
int foundFlag = FALSE;
xmlNode *texn = NULL;
@@ -304,7 +304,7 @@ int processMesh(xmlNode *n, FILE *outfile)
printf("Could not find <Texture> element!\n");
return FALSE;
}
memset(texname, 0, NAMESIZE);
memset(texname, 0, NAMESIZE+1);
strncpy((char*)texname,
(char*)xmlGetProp(texn, (xmlChar*)"name"), NAMESIZE);
fwrite(texname, NAMESIZE, 1, outfile);