Skip to content
Permalink
Browse files

Merge remote-tracking branch 'remotes/origin/MP2-819_Fix_LVCT_parser'…

… into MP_1.23.100_Pre_Release_Test5
  • Loading branch information
Azzuro committed Jan 6, 2020
2 parents 8cbba2b + c33fe87 commit 172f148e4e8cb442bd3456368266399967bccde4
Showing with 51 additions and 22 deletions.
  1. +51 −22 DirectShowFilters/TsWriter/source/LvctParser.cpp
@@ -220,10 +220,10 @@ void CLvctParser::OnNewSection(CSection& sections)
{
shortNameLength = strlen(name);
}
for (size_t i = 0; i < extendedNames.size(); i++)
for (size_t n = 0; n < extendedNames.size(); n++)
{
int extendedNameLength = strlen(extendedNames[i]);
if (extendedNameLength == shortNameLength && strcmp(name, extendedNames[0]) == 0)
int extendedNameLength = strlen(extendedNames[n]);
if (extendedNameLength == shortNameLength && strcmp(name, extendedNames[n]) == 0)
{
continue;
}
@@ -237,23 +237,22 @@ void CLvctParser::OnNewSection(CSection& sections)
if (newName == NULL)
{
LogDebug("LvctParser: failed to allocate %d bytes for the extended name", nameBufferSize);
continue;
}
else
{
strcpy(newName, extendedNames[i]);
if (name != NULL)
{
strcat(newName, " (");
strcat(newName, name);
strcat(newName, ")");
delete[] name;
}
name = newName;
}
for (vector<char*>::iterator it = extendedNames.begin(); it != extendedNames.end(); it++)
strcpy(newName, extendedNames[n]);
if (name != NULL)
{
delete[] *it;
strcat(newName, " (");
strcat(newName, name);
strcat(newName, ")");
delete[] name;
}
name = newName;
break;
}
for (auto& extendedName : extendedNames)
{
delete[] extendedName;
}
}
else if (tag == 0xa1) // service location descriptor
@@ -390,6 +389,9 @@ void CLvctParser::DecodeMultipleStrings(byte* b, int length, vector<char*>* stri
pointer += 3;
int numberSegments = b[pointer++];
//LogDebug("LvctParser: string %d, number of segments = %d", i, numberSegments);

vector<char*> segments;
int segmentCharCount = 0;
for (int j = 0; j < numberSegments && pointer + 2 < length; j++)
{
int compressionType = b[pointer++];
@@ -402,20 +404,47 @@ void CLvctParser::DecodeMultipleStrings(byte* b, int length, vector<char*>* stri
return;
}

char* string = NULL;
DecodeString(&b[pointer], compressionType, mode, numberBytes, &string);
if (string != NULL)
char* segment = NULL;
DecodeString(&b[pointer], compressionType, mode, numberBytes, &segment);
if (segment != NULL)
{
strings->push_back(string);
segments.push_back(segment);
segmentCharCount += strlen(segment);
}

pointer += numberBytes;
}

// combine the segments to produce the final string
if (segments.empty())
{
continue;
}
if (segments.size() == 1)
{
strings->push_back(segments[0]);
continue;
}

char* string = new char[segmentCharCount + 1];
if (string == NULL)
{
LogDebug("LvctParser: failed to allocate %d bytes in DecodeMultipleStrings()", segmentCharCount + 1);
continue;
}

string[0] = 0; // start with an empty string
for (auto& segment : segments)
{
strcat(string, segment);
delete[] segment;
}
strings->push_back(string);
}
}
catch (...)
{
LogDebug("LvctParser: unhandled exception in ParseMultipleStrings()");
LogDebug("LvctParser: unhandled exception in DecodeMultipleStrings()");
}
}

0 comments on commit 172f148

Please sign in to comment.
You can’t perform that action at this time.