From: Dale Weiler Date: Fri, 21 Jun 2013 23:49:08 +0000 (+0000) Subject: Improper use of a possible negative value. X-Git-Tag: v0.3.0~94 X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=commitdiff_plain;h=1929b129eeb4ed27fd50d433d4a8b36f41b7d750 Improper use of a possible negative value. --- diff --git a/pak.c b/pak.c index 35e605c..ee64738 100644 --- a/pak.c +++ b/pak.c @@ -427,8 +427,16 @@ static bool pak_close(pak_file_t *pak) { * our directory entries at the end of the file. */ if (pak->insert) { + int tell = fs_file_tell(pak->handle); + if (tell < 0) { + vec_free (pak->directories); + fs_file_close(pak->handle); + mem_d (pak); + + return false; + } pak->header.dirlen = vec_size(pak->directories) * 64; - pak->header.diroff = ftell(pak->handle); + pak->header.diroff = tell; /* patch header */ fs_file_seek (pak->handle, 0, SEEK_SET);