From fa9962276f9066f0caa714432a4c4dca476e96a1 Mon Sep 17 00:00:00 2001 From: jcdr428 <56721609+jcdr428@users.noreply.github.com> Date: Thu, 2 Jan 2020 00:04:15 +0100 Subject: [PATCH] Update textSubtitlesRender (#102) * Update textSubtitleRender Solve build warnings related to potential overflows in int to size_t conversions. --- tsMuxer/textSubtitlesRender.cpp | 8 ++++---- tsMuxer/textSubtitlesRender.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tsMuxer/textSubtitlesRender.cpp b/tsMuxer/textSubtitlesRender.cpp index f1272899..d97521ff 100644 --- a/tsMuxer/textSubtitlesRender.cpp +++ b/tsMuxer/textSubtitlesRender.cpp @@ -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; @@ -296,13 +296,13 @@ vector > 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)); @@ -325,7 +325,7 @@ vector > 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) { diff --git a/tsMuxer/textSubtitlesRender.h b/tsMuxer/textSubtitlesRender.h index cbdef4cf..d4e0e83b 100644 --- a/tsMuxer/textSubtitlesRender.h +++ b/tsMuxer/textSubtitlesRender.h @@ -117,7 +117,7 @@ class TextSubtitlesRender { int getRepeatCnt(uint32_t* pos, uint32_t* end); std::vector > processTxtLine(const std::wstring& line, std::vector& 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; };