From 6df325f6510b3dc042601ec40842d04355539322 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 30 Jun 2016 09:29:32 +0100 Subject: [PATCH] Added handling of error return type --- src/osgPlugins/txp/trpage_rarchive.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/osgPlugins/txp/trpage_rarchive.cpp b/src/osgPlugins/txp/trpage_rarchive.cpp index 6f5afdca1..6ce4abdd8 100644 --- a/src/osgPlugins/txp/trpage_rarchive.cpp +++ b/src/osgPlugins/txp/trpage_rarchive.cpp @@ -413,15 +413,21 @@ bool trpgr_Archive::ReadExternalTile(uint32 x,uint32 y,uint32 lod,trpgMemReadBuf // Find the file end if (fseek(filep,0,SEEK_END)) throw 1; + // Note: This means tile is capped at 2 gigs long pos = ftell(filep); + if (pos<0) + throw 1; + if (fseek(filep,0,SEEK_SET)) throw 1; + // Now we know the size. Read the whole file buf.SetLength(pos); char *data = buf.GetDataPtr(); if (fread(data,pos,1,filep) != 1) throw 1; + fclose(filep); filep = NULL; }