diff --git a/Source/d_main.c b/Source/d_main.c index 4610fea1..53cb73b8 100644 --- a/Source/d_main.c +++ b/Source/d_main.c @@ -980,6 +980,7 @@ void FindResponseFile (void) file = malloc (size); if (!fread(file,size,1,handle)) { + fclose(handle); free(file); return; } diff --git a/Source/st_stuff.c b/Source/st_stuff.c index 0797119a..3c435af4 100644 --- a/Source/st_stuff.c +++ b/Source/st_stuff.c @@ -791,7 +791,7 @@ void ST_loadGraphics(void) { sprintf(namebuf, "STTNUM%d", i); tallnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); - sprintf(namebuf, "STYSNUM%d", i); + snprintf(namebuf, sizeof(namebuf), "STYSNUM%d", i); shortnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); } diff --git a/Source/w_wad.c b/Source/w_wad.c index 6b0c1f09..2ac1da56 100644 --- a/Source/w_wad.c +++ b/Source/w_wad.c @@ -177,7 +177,8 @@ static void W_AddFile(const char *name) // killough 1/31/98: static, const else { // WAD file - read(handle, &header, sizeof(header)); + if (!read(handle, &header, sizeof(header))) + I_Error("Wad file %s doesn't have IWAD or PWAD id\n", filename); if (strncmp(header.identification,"IWAD",4) && strncmp(header.identification,"PWAD",4)) I_Error("Wad file %s doesn't have IWAD or PWAD id\n", filename); @@ -186,7 +187,8 @@ static void W_AddFile(const char *name) // killough 1/31/98: static, const length = header.numlumps*sizeof(filelump_t); fileinfo2free = fileinfo = malloc(length); // killough lseek(handle, header.infotableofs, SEEK_SET); - read(handle, fileinfo, length); + if (!read(handle, fileinfo, length)) + I_Error("Error reading lump directory from %s\n", filename); numlumps += header.numlumps; }