X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=pak.c;h=5cece63d6122964acacd550141571c575339a148;hp=ee647382da59cac608f009cc43cf0dc6b14157a1;hb=a9ab865add301e49390d1ebeabe350a6c9c4205c;hpb=1929b129eeb4ed27fd50d433d4a8b36f41b7d750 diff --git a/pak.c b/pak.c index ee64738..5cece63 100644 --- a/pak.c +++ b/pak.c @@ -334,6 +334,7 @@ static bool pak_extract_all(pak_file_t *pak, const char *dir) { static bool pak_insert_one(pak_file_t *pak, const char *file) { pak_directory_t dir; unsigned char *dat; + long len; FILE *fp; /* @@ -353,9 +354,13 @@ static bool pak_insert_one(pak_file_t *pak, const char *file) { * to the PAK file itself. */ fs_file_seek(fp, 0, SEEK_END); - dir.len = fs_file_tell(fp); + if ((len = fs_file_tell(fp)) < 0) { + fs_file_close(fp); + return false; + } fs_file_seek(fp, 0, SEEK_SET); + dir.len = len; dir.pos = fs_file_tell(pak->handle); /*