Skip to content

Commit

Permalink
feat(linux): prevent buffer overrun #11910
Browse files Browse the repository at this point in the history
  • Loading branch information
SabineSIL committed Jul 3, 2024
1 parent 683c062 commit d40ef15
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions linux/mcompile/keymap/u16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,11 @@ int u16ncmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) {
return 0;
}

KMX_WCHAR * u16tok(KMX_WCHAR *p, KMX_WCHAR ch, KMX_WCHAR **ctx) {
KMX_WCHAR * u16tok(KMX_WCHAR *p, const KMX_WCHAR ch, KMX_WCHAR **ctx) {
if (!p) {
p = *ctx;
if (!p) return NULL;
}

KMX_WCHAR *q = p;
while (*q && *q != ch) {
q++;
Expand All @@ -247,7 +246,7 @@ KMX_WCHAR * u16tok(KMX_WCHAR *p, KMX_WCHAR ch, KMX_WCHAR **ctx) {
else {
*ctx = NULL;
}
return p;
return *p ? p : NULL;
}

// _S2 delimiters is array of char ( of size 2)
Expand All @@ -264,13 +263,13 @@ KMX_WCHAR * u16tok(KMX_WCHAR* p, KMX_WCHAR* delimiters, KMX_WCHAR** ctx) {
if (*q) {
*q = 0;
q++;
while (u16chr(delimiters, *q)) q++;
while (*q && u16chr(delimiters, *q)) q++;
*ctx = q;
}
else {
*ctx = NULL;
}
return p;
return *p ? p : NULL;
}

double u16tof( KMX_WCHAR* str)
Expand Down

0 comments on commit d40ef15

Please sign in to comment.