Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed Jul 30, 2019
1 parent bb9c949 commit c0afd95
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/ResToText.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1173,15 +1173,17 @@ inline MString ResToText::DoFontDir(const EntryBase& entry)

WORD wCount = *(const WORD *)pb;

if (size < sizeof(WORD) + 165 * wCount)
{
return str;
}

TCHAR szText[64];
StringCbPrintf(szText, sizeof(szText), TEXT("Count: %d\r\n---\r\n"), wCount);
str += szText;

#define FONTDIRENTRYSIZE 165
if (size < sizeof(WORD) + FONTDIRENTRYSIZE * wCount)
{
// NOTE: I think windres RT_FONTDIR is broken. Just ignore it.
return str;
}

pb += 2;
for (WORD i = 0; i < wCount; ++i)
{
Expand Down Expand Up @@ -1211,10 +1213,11 @@ inline MString ResToText::DoFontDir(const EntryBase& entry)
}

str += TEXT(")\r\n");
pb += 165;
pb += FONTDIRENTRYSIZE;
}

return str;
#undef FONTDIRENTRYSIZE
}

inline MString ResToText::DumpName(const MIdOrString& type, const MIdOrString& name)
Expand Down

0 comments on commit c0afd95

Please sign in to comment.