Merge pull request #40928 from bruvzg/fix_test_heap_use_after_free

Fix heap use after free in the doctest "main".
This commit is contained in:
Rémi Verschelde 2020-07-31 21:21:18 +02:00 committed by GitHub
commit 29df1919e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -70,7 +70,8 @@ int test_main(int argc, char *argv[]) {
char **args = new char *[valid_arguments.size()]; char **args = new char *[valid_arguments.size()];
for (int x = 0; x < valid_arguments.size(); x++) { for (int x = 0; x < valid_arguments.size(); x++) {
// Operation to convert Godot string to non wchar string. // Operation to convert Godot string to non wchar string.
const char *str = valid_arguments[x].utf8().ptr(); CharString cs = valid_arguments[x].utf8();
const char *str = cs.get_data();
// Allocate the string copy. // Allocate the string copy.
args[x] = new char[strlen(str) + 1]; args[x] = new char[strlen(str) + 1];
// Copy this into memory. // Copy this into memory.