Skip to content

Commit

Permalink
Update textSubtitlesRender (#102)
Browse files Browse the repository at this point in the history
* Update textSubtitleRender

Solve build warnings related to potential overflows in int to size_t conversions.
  • Loading branch information
jcdr428 authored and lighterowl committed Jan 1, 2020
1 parent cc35894 commit fa99622
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tsMuxer/textSubtitlesRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ wstring findFontArg(const wstring& text, int pos)
return L"";
}

int TextSubtitlesRender::findUnquotedStrW(const wstring& str, const wstring& substr)
size_t TextSubtitlesRender::findUnquotedStrW(const wstring& str, const wstring& substr)
{
if (substr.size() == 0)
return string::npos;
Expand Down Expand Up @@ -296,13 +296,13 @@ vector<pair<Font,wstring> > TextSubtitlesRender::processTxtLine(const std::wstri
}
else if (strStartWithW(ltagStr, L"font "))
{
int fontNamePos = findUnquotedStrW(ltagStr, L"name"); //ltagStr.find(L"name");
size_t fontNamePos = findUnquotedStrW(ltagStr, L"name"); //ltagStr.find(L"name");
if (fontNamePos == string::npos)
fontNamePos = findUnquotedStrW(ltagStr, L"face");
if (fontNamePos != string::npos)
curFont.m_name = unquoteStrW(findFontArg(tagStr, fontNamePos/*, lastIndexPos*/));

int colorPos = findUnquotedStrW(ltagStr, L"color");
size_t colorPos = findUnquotedStrW(ltagStr, L"color");
if (colorPos != string::npos)
{
wstring arg = unquoteStrW(findFontArg(ltagStr, colorPos));
Expand All @@ -325,7 +325,7 @@ vector<pair<Font,wstring> > TextSubtitlesRender::processTxtLine(const std::wstri
if ((curFont.m_color & 0xff000000u) == 0)
curFont.m_color |= 0xff000000u;
}
int fontSizePos = findUnquotedStrW(ltagStr, L"size");
size_t fontSizePos = findUnquotedStrW(ltagStr, L"size");
if (fontSizePos != string::npos) {
wstring arg = unquoteStrW(findFontArg(tagStr, fontSizePos));
if (arg.size() > 0) {
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/textSubtitlesRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class TextSubtitlesRender {
int getRepeatCnt(uint32_t* pos, uint32_t* end);
std::vector<std::pair<Font,std::wstring> > processTxtLine(const std::wstring& line, std::vector<Font>& fontStack);
int browserSizeToRealSize(int bSize, double rSize);
int findUnquotedStrW(const std::wstring& str, const std::wstring& substr);
size_t findUnquotedStrW(const std::wstring& str, const std::wstring& substr);
private:
Font m_initFont;
};
Expand Down

0 comments on commit fa99622

Please sign in to comment.