Skip to content

Commit

Permalink
Merge pull request from GHSA-cfcv-789h-3pg3
Browse files Browse the repository at this point in the history
GHSL-2023-112: check if the current pointer and the next one are less than the end
  • Loading branch information
donho committed Sep 1, 2023
2 parents fb1985d + 6567a89 commit 4b66d80
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion PowerEditor/src/Utf8_16.cpp
Expand Up @@ -152,7 +152,7 @@ size_t Utf8_16_Read::convert(char* buf, size_t len)
case uni16LE_NoBOM:
case uni16BE:
case uni16LE: {
size_t newSize = len + len / 2 + 1;
size_t newSize = (len + len % 2) + (len + len % 2) / 2;

if (m_nAllocatedBufSize != newSize)
{
Expand Down
4 changes: 3 additions & 1 deletion PowerEditor/src/Utf8_16.h
Expand Up @@ -53,7 +53,9 @@ class Utf16_Iter : public Utf8_16 {
bool get(utf8 *c);
void operator++();
eState getState() { return m_eState; };
operator bool() { return (m_pRead < m_pEnd) || (m_out1st != m_outLst); };
// Utf8_16::read always consumes two bytes,
// thus the bool operator checks if m_pRead is less than m_pEnd by two bytes.
operator bool() { return (m_pRead + 1 < m_pEnd) || (m_out1st != m_outLst); };

protected:
void read();
Expand Down

0 comments on commit 4b66d80

Please sign in to comment.