static bool pak_insert_one(pak_file_t *pak, const char *file) {
pak_directory_t dir;
unsigned char *dat;
+ long len;
FILE *fp;
/*
* 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);
/*