Skip to content

Commit

Permalink
make MLUgetWide() avoid unintentional memmove
Browse files Browse the repository at this point in the history
  • Loading branch information
x2018 committed Nov 8, 2023
1 parent 6491e2e commit bf94c4b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cmsnamed.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,12 +645,12 @@ cmsUInt32Number CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu,
// Maybe we want only to know the len?
if (Buffer == NULL) return StrLen + sizeof(wchar_t);

// No buffer size means no data
if (BufferSize <= 0) return 0;
// Invalid buffer size means no data
if (BufferSize < sizeof(wchar_t)) return 0;

// Some clipping may be required
if (BufferSize < StrLen + sizeof(wchar_t))
StrLen = BufferSize - + sizeof(wchar_t);
StrLen = BufferSize - sizeof(wchar_t);

memmove(Buffer, Wide, StrLen);
Buffer[StrLen / sizeof(wchar_t)] = 0;
Expand Down

0 comments on commit bf94c4b

Please sign in to comment.