Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YGOPRO-520DIY
ygopro
Commits
753a372b
Commit
753a372b
authored
May 03, 2024
by
salix5
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DecodeUTF8: check array size
parent
81d0ef16
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
gframe/bufferio.h
gframe/bufferio.h
+18
-5
No files found.
gframe/bufferio.h
View file @
753a372b
...
...
@@ -110,20 +110,33 @@ public:
return
pstr
-
str
;
}
// UTF-8 to UTF-16/UTF-32
static
int
DecodeUTF8
(
const
char
*
src
,
wchar_t
*
wstr
)
{
template
<
size_t
N
>
static
int
DecodeUTF8
(
const
char
*
src
,
wchar_t
(
&
wstr
)[
N
])
{
const
char
*
p
=
src
;
wchar_t
*
wp
=
wstr
;
while
(
*
p
!=
0
)
{
if
(((
unsigned
)
*
p
&
0x80
)
==
0
)
{
const
unsigned
cur
=
(
unsigned
)
*
p
&
0xff
;
int
codepoint_size
=
0
;
if
((
cur
&
0xf8
)
==
0xf0
)
{
if
(
sizeof
(
wchar_t
)
==
2
)
codepoint_size
=
2
;
else
codepoint_size
=
1
;
}
else
codepoint_size
=
1
;
if
(
wp
-
wstr
+
codepoint_size
>
N
-
1
)
break
;
if
((
cur
&
0x80
)
==
0
)
{
*
wp
=
*
p
;
p
++
;
}
else
if
((
(
unsigned
)
*
p
&
0xe0
)
==
0xc0
)
{
}
else
if
((
cur
&
0xe0
)
==
0xc0
)
{
*
wp
=
(((
unsigned
)
p
[
0
]
&
0x1f
)
<<
6
)
|
((
unsigned
)
p
[
1
]
&
0x3f
);
p
+=
2
;
}
else
if
((
(
unsigned
)
*
p
&
0xf0
)
==
0xe0
)
{
}
else
if
((
cur
&
0xf0
)
==
0xe0
)
{
*
wp
=
(((
unsigned
)
p
[
0
]
&
0xf
)
<<
12
)
|
(((
unsigned
)
p
[
1
]
&
0x3f
)
<<
6
)
|
((
unsigned
)
p
[
2
]
&
0x3f
);
p
+=
3
;
}
else
if
((
(
unsigned
)
*
p
&
0xf8
)
==
0xf0
)
{
}
else
if
((
cur
&
0xf8
)
==
0xf0
)
{
if
(
sizeof
(
wchar_t
)
==
2
)
{
unsigned
unicode
=
(((
unsigned
)
p
[
0
]
&
0x7
)
<<
18
)
|
(((
unsigned
)
p
[
1
]
&
0x3f
)
<<
12
)
|
(((
unsigned
)
p
[
2
]
&
0x3f
)
<<
6
)
|
((
unsigned
)
p
[
3
]
&
0x3f
);
unicode
-=
0x10000
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment