+/*
+WARNING: DO NOT UNCRUSTIFY
+It will still compile after an uncrustify, but it will be *broken*
+See https://github.com/TTimo/GtkRadiant/issues/33
+*/
+
/*
Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
{
short v;
- fread( &v, sizeof(v), 1, fin );
+ if ( fread( &v, sizeof( v ), 1, fin ) != 1 ) {
+ return UNZ_EOF;
+ }
*pX = __LittleShort( v);
return UNZ_OK;
{
int v;
- fread( &v, sizeof(v), 1, fin );
+ if ( fread( &v, sizeof( v ), 1, fin ) != 1 ) {
+ return UNZ_EOF;
+ }
*pX = __LittleLong( v);
return UNZ_OK;
/* we check the magic */
- if (err==UNZ_OK)
+ if (err==UNZ_OK) {
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x02014b50)
err=UNZ_BADZIPFILE;
+ }
if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
err=UNZ_ERRNO;
else
uSizeRead = extraFieldBufferSize;
- if (lSeek!=0)
+ if (lSeek!=0) {
if (fseek(s->file,lSeek,SEEK_CUR)==0)
lSeek=0;
else
err=UNZ_ERRNO;
+ }
if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
err=UNZ_ERRNO;
else
uSizeRead = commentBufferSize;
- if (lSeek!=0)
+ if (lSeek!=0) {
if (fseek(s->file,lSeek,SEEK_CUR)==0)
lSeek=0;
else
err=UNZ_ERRNO;
+ }
if ((file_info.size_file_comment>0) && (commentBufferSize>0))
if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
err=UNZ_ERRNO;
return UNZ_ERRNO;
- if (err==UNZ_OK)
+ if (err==UNZ_OK) {
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x04034b50)
err=UNZ_BADZIPFILE;
+ }
if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
err=UNZ_ERRNO;
/* compute minimum size table less than or equal to l bits */
z = g - w;
- z = z > (uInt)l ? l : z; /* table size upper limit */
+ z = z > (uInt)l ? (uInt)l : z; /* table size upper limit */
if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
{ /* too few codes for k-w bit table */
f -= a + 1; /* deduct codes from patterns left */