Hi,
I work under windows, and which platform do you work?
linux's "open" function's description is:
Return Value
Upon successful completion, the function shall open the file and return a
non-negative integer representing the lowest numbered unused file descriptor.
Otherwise, -1 shall be returned and errno set to indicate the error. No files
shall be created or modified if the function returns -1.
so I think it's never return 0, because 0 is usually represent "Standard input
(stdin)".
If function fail, it should return -1, i think.
chaoswong
------------------ Original ------------------
From: "Ulrich Hertlein"<[email protected]>;
Date: Tue, Jul 23, 2013 09:12 PM
To: "OpenSceneGraph Users"<[email protected]>;
"ChaosWong"<[email protected]>;
Cc: "osg-users"<[email protected]>;
Subject: Re: [osg-users] osgdb_shp plugin's XBaseParser may have aerror
Hello ChaosWong,
Quoting ChaosWong <[email protected]>:
> i develop osg application under windows. when i was loading a .shp
> file, my application was crashed. after i tracked, i found i miss a
> .bdf file, and code was crashed at red line:
>
> XBaseParser::XBaseParser(const std::string fileName):
> _valid(false)
> {
> int fd = 0;
> if (fileName.empty() == false)
> {
> #ifdef WIN32
> if( (fd = open( fileName.c_str(), O_RDONLY | O_BINARY )) <= 0 )
> #else
> if( (fd = ::open( fileName.c_str(), O_RDONLY )) <= 0 )
> #endif
> {
> perror( fileName.c_str() );
> if (fd) close( fd );
> return;
> }
> }
>
> _valid = parse(fd);
> }
I don't have the code available, but the whole piece looks fishy to me:
- if the fileName is empty, it calls 'parse(fd)' with fd==0
- if the fileName is valid, it opens the file and calls 'parse(fd)',
but leaks the file descriptor
- god only knows what happens when an exception is thrown
Cheers,
/ulrich
._______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org