mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Fix possible heap corruption when converting to NSNonLossyASCIIStringEncoding.
This commit is contained in:
parent
a4f30a33cf
commit
47ed291b80
2 changed files with 18 additions and 2 deletions
|
@ -2242,12 +2242,22 @@ GSFromUnicode(unsigned char **dst, unsigned int *size, const unichar *src,
|
|||
}
|
||||
else
|
||||
{
|
||||
dpos += sprintf((char*)&ptr[dpos], "\\%03o", u);
|
||||
char octchars[] = "01234567";
|
||||
ptr[dpos++] = '\\';
|
||||
ptr[dpos++] = octchars[(u >> 6) & 7];
|
||||
ptr[dpos++] = octchars[(u >> 3) & 7];
|
||||
ptr[dpos++] = octchars[u & 7];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dpos += sprintf((char*)&ptr[dpos], "\\u%04x", u);
|
||||
char hexchars[] = "0123456789abcdef";
|
||||
ptr[dpos++] = '\\';
|
||||
ptr[dpos++] = 'u';
|
||||
ptr[dpos++] = hexchars[(u >> 12) & 0xF];
|
||||
ptr[dpos++] = hexchars[(u >> 8) & 0xF];
|
||||
ptr[dpos++] = hexchars[(u >> 4) & 0xF];
|
||||
ptr[dpos++] = hexchars[u & 0xF];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue