[Live-devel] Problem! If Matroska file not exist

kingking kuo kevinkuokingking at hotmail.com
Mon Aug 27 21:53:48 PDT 2012


> > > If Matroska if is not exist the program will crash.> > > > 1. In MatroskaFile.cpp > > > > fParserForInitialization> > = new MatroskaFileParser(*this, ByteStreamFileSource::createNew(envir(), fileName),> > handleEndOfTrackHeaderParsing, this, NULL); > [...]> > // if Matroska file is not exist, the fParserForInitialization is a invalid pointer.> > No, that should not be the case. If the file "fileName" does not exist, then the call to "ByteStreamFileSource::createNew(envir(), fileName)" will return NULL, and therefore the "MatroskaFileParser" constructor will be called with an "inputSource" parameter of NULL. This will cause the "fInputSource" member variable to get set to NULL. That should be OK, because we always check that "fInputSource" is NULL before we try to dereference it. But in any case, a valid "MatroskaFileParser" object should be constructed, and thus "fParserForInitialization" should be valid (and non-NULL).> > I won't rule out the possibility of there being some problem with the code if the file "fileName" does not exist, but if there is, then it's not what you described.> > 
Yes, If the file "filename" does not exist, then "ByteStreamFileSource::createNew(envir(), fileName)" will return NULL, and therefore the "MatroskaFileParser" constructor will be called with an "inputSource" parameter of NULL. This will cause the "fInputSource" member variable to get set to NULL. 
but, In void MatroskaFileParser::continueParsing() call, the "if (fOnEndFunc != NULL) (*fOnEndFunc)(fOnEndClientData);" will call, then will call "void MatroskaFile::handleEndOfTrackHeaderParsing()", and this time the "fParserForInitialization" is a invalid pointer, delete the invalid pointer will crash.
note: I create a solution in vs 2008 ,and i add the file into the solution, I can complie and build the solution, If I need additions settings?
thanks. 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120828/064e0fe2/attachment.html>


More information about the live-devel mailing list