diff options
| -rw-r--r-- | indra/llcommon/llapr.cpp | 16 | ||||
| -rw-r--r-- | indra/llcommon/llapr.h | 4 | 
2 files changed, 12 insertions, 8 deletions
diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index ed70b1d9f2..f030867ec4 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -535,6 +535,11 @@ S32 LLAPRFile::seek(apr_file_t* file_handle, apr_seek_where_t where, S32 offset)  //static  S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool)  { +	if (offset < 0) +	{ +		return 0; // do nothing, negative offsets don't make sense for reads +	} +  	//*****************************************  	apr_file_t* file_handle = open(filename, pool, APR_READ|APR_BINARY);   	//*****************************************	 @@ -543,14 +548,13 @@ S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nb  		return 0;  	} -	S32 off; -	if (offset < 0) -		off = LLAPRFile::seek(file_handle, APR_END, 0); -	else -		off = LLAPRFile::seek(file_handle, APR_SET, offset); +	if (offset > 0) +	{ +		offset = LLAPRFile::seek(file_handle, APR_SET, offset); +	}  	apr_size_t bytes_read; -	if (off < 0) +	if (offset < 0)  	{  		bytes_read = 0;  	} diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index c1ad0bfed1..08cf11e593 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -255,12 +255,12 @@ public:  	// Returns bytes read/written, 0 if read/write fails:  	static S32 readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL);	 -	static S32 writeEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL);	 +	static S32 writeEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL); // offset<0 means append  //*******************************************************************************************************************************  };  /** - * @brief Function which approprately logs error or remains quiet on + * @brief Function which appropriately logs error or remains quiet on   * APR_SUCCESS.   * @return Returns <code>true</code> if status is an error condition.   */  | 
