Block parsing is now robust
Previously, parsing of a Block element was done inside its constructor. Parsing errors were handled via assertion checks, but this only works in practice if there are no actual errors in the file. We did come across a file, however, that used EMBL-style lacing, but the lacing was done incorrectly and so the parse asserted. This isn't acceptable for a production system, and more a graceful handling of parse errors was needed. The code was restructured such that the Block object's ctor does only trivial initialization of member variables. A separate Parse method was added, that is called after the object is constructed. If the parse succeeds all is well, otherwise the object is destroyed and the error is reported to the caller. This commit fixes bug tracker issue #398, described here: http://code.google.com/p/webm/issues/detail?id=398 Change-Id: Ib95ca95d0eec08cf670b308c461e42ed8345e890
This commit is contained in:
@@ -317,7 +317,15 @@ int main(int argc, char* argv[]) {
|
||||
const mkvparser::Cluster* cluster = parser_segment->GetFirst();
|
||||
|
||||
while ((cluster != NULL) && !cluster->EOS()) {
|
||||
const mkvparser::BlockEntry* block_entry = cluster->GetFirst();
|
||||
const mkvparser::BlockEntry* block_entry;
|
||||
|
||||
long status = cluster->GetFirst(block_entry);
|
||||
|
||||
if (status)
|
||||
{
|
||||
printf("\n Could not get first block of cluster.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while ((block_entry != NULL) && !block_entry->EOS()) {
|
||||
const mkvparser::Block* const block = block_entry->GetBlock();
|
||||
@@ -362,7 +370,13 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
block_entry = cluster->GetNext(block_entry);
|
||||
status = cluster->GetNext(block_entry, block_entry);
|
||||
|
||||
if (status)
|
||||
{
|
||||
printf("\n Could not get next block of cluster.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
cluster = parser_segment->GetNext(cluster);
|
||||
|
||||
Reference in New Issue
Block a user