Fixed crash when open(..) returns an error.

This commit is contained in:
Robert Osfield
2013-07-23 09:54:28 +00:00
parent 21b5109089
commit 0483912e32

View File

@@ -87,13 +87,12 @@ XBaseParser::XBaseParser(const std::string fileName):
if (fileName.empty() == false)
{
#ifdef WIN32
if( (fd = open( fileName.c_str(), O_RDONLY | O_BINARY )) <= 0 )
if( (fd = open( fileName.c_str(), O_RDONLY | O_BINARY )) < 0 )
#else
if( (fd = ::open( fileName.c_str(), O_RDONLY )) <= 0 )
if( (fd = ::open( fileName.c_str(), O_RDONLY )) < 0 )
#endif
{
perror( fileName.c_str() );
if (fd) close( fd );
return;
}
}