Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
4f49d092
Commit
4f49d092
authored
Feb 22, 2019
by
Hein-Pieter van Braam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't crash when parse_utf8 receives a NULL pointer
This can happen when chaining calls to various string methods when the string is empty.
parent
aef5b36b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
ustring.cpp
core/ustring.cpp
+3
-0
test_string.cpp
main/tests/test_string.cpp
+8
-0
No files found.
core/ustring.cpp
View file @
4f49d092
...
...
@@ -1359,6 +1359,9 @@ bool String::parse_utf8(const char *p_utf8, int p_len) {
#define _UNICERROR(m_err) print_line("Unicode error: " + String(m_err));
if
(
!
p_utf8
)
return
true
;
String
aux
;
int
cstr_size
=
0
;
...
...
main/tests/test_string.cpp
View file @
4f49d092
...
...
@@ -1046,6 +1046,13 @@ bool test_32() {
#undef STRIP_TEST
}
bool
test_33
()
{
OS
::
get_singleton
()
->
print
(
"
\n\n
Test 33: parse_utf8(null, -1)
\n
"
);
String
empty
;
return
empty
.
parse_utf8
(
NULL
,
-
1
)
==
true
;
}
typedef
bool
(
*
TestFunc
)(
void
);
TestFunc
test_funcs
[]
=
{
...
...
@@ -1082,6 +1089,7 @@ TestFunc test_funcs[] = {
test_30
,
test_31
,
test_32
,
test_33
,
0
};
...
...
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