Skip to content

Commit

Permalink
tidy: Fix a bunch of null dereference warnings in test_mpegtables.
Browse files Browse the repository at this point in the history
The clang-tidy "null dereference" checker pointed out a bunch of
potential null dereferences in the test_mpegtables code.  The
dereferences are not obvious, as they occur inside of functions from
mpegdescriptors.h that have been inlined into the test code.  Adding
simple tests for descriptor validity, and exiting when they aren't
valid, eliminates all these warnings.
  • Loading branch information
linuxdude42 committed Apr 1, 2019
1 parent 528c0c9 commit 91f2933
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion mythtv/libs/libmythtv/test/test_mpegtables/test_mpegtables.cpp
Expand Up @@ -263,13 +263,20 @@ void TestMPEGTables::PrivateUPCCablecomEpisodetitleDescriptor_test (void)
void TestMPEGTables::ItemList_test (void)
{
ShortEventDescriptor descriptor(&eit_data_0000[26]);
QVERIFY (descriptor.IsValid());
if (!descriptor.IsValid()) {
QFAIL("The eit_data_0000 descriptor is invalid");
return;
}
QCOMPARE (descriptor.DescriptorTag(), (unsigned int) DescriptorID::short_event);
QCOMPARE (descriptor.size(), (unsigned int) 194);
QCOMPARE (descriptor.LanguageString(), QString("ger"));
QVERIFY (descriptor.Text().startsWith(QString("Krimiserie. ")));

ExtendedEventDescriptor descriptor2(&eit_data_0000[26+descriptor.size()]);
if (!descriptor2.IsValid()) {
QFAIL("The eit_data_0000 descriptor2 is invalid");
return;
}
QCOMPARE (descriptor2.DescriptorTag(), (unsigned int) DescriptorID::extended_event);
/* tests for items start here */
QCOMPARE (descriptor2.LengthOfItems(), (uint) 139);
Expand Down Expand Up @@ -306,6 +313,10 @@ void TestMPEGTables::ParentalRatingDescriptor_test (void)
void TestMPEGTables::ExtendedEventDescriptor_test (void)
{
ExtendedEventDescriptor desc(&eit_data_0000[16*13+12]);
if (!desc.IsValid()) {
QFAIL("The eit_data_0000 descriptor is invalid");
return;
}
QCOMPARE (desc.LengthOfItems(), 139U);
QMultiMap<QString,QString> items = desc.Items();
QCOMPARE (items.count(), 5);
Expand Down

0 comments on commit 91f2933

Please sign in to comment.