Kaydet (Commit) 7d9b6119 authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#706217 Time of check time of use

Change-Id: I762658a01e97f56b2f9362a38a0fefc941698d1b
üst 5c4a9b1e
...@@ -112,24 +112,21 @@ class FileInputStream ...@@ -112,24 +112,21 @@ class FileInputStream
} }
}; };
FileInputStream::FileInputStream( const char* pFilename ) : FileInputStream::FileInputStream(const char* pFilename)
m_pMemory( NULL ), : m_pMemory(NULL)
m_nPos( 0 ), , m_nPos(0)
m_nLen( 0 ) , m_nLen(0)
{ {
struct stat aStat; FILE* fp = fopen( pFilename, "r" );
if( ! stat( pFilename, &aStat ) && if( fp )
S_ISREG( aStat.st_mode ) &&
aStat.st_size > 0
)
{ {
FILE* fp = fopen( pFilename, "r" ); struct stat aStat;
if( fp ) if (!fstat(fileno(fp), &aStat) && S_ISREG(aStat.st_mode) && aStat.st_size > 0)
{ {
m_pMemory = (char*)rtl_allocateMemory( aStat.st_size ); m_pMemory = (char*)rtl_allocateMemory( aStat.st_size );
m_nLen = (unsigned int)fread( m_pMemory, 1, aStat.st_size, fp ); m_nLen = (unsigned int)fread( m_pMemory, 1, aStat.st_size, fp );
fclose( fp );
} }
fclose( fp );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment