Fix heap use after free in the doctest "main".

This commit is contained in:
bruvzg 2020-07-31 21:52:48 +03:00
parent 970ce06b34
commit 0a89498f51
No known key found for this signature in database
GPG Key ID: FCED35F1CECE0D3A
1 changed files with 2 additions and 1 deletions

View File

@ -69,7 +69,8 @@ int test_main(int argc, char *argv[]) {
char **args = new char *[valid_arguments.size()];
for (int x = 0; x < valid_arguments.size(); x++) {
// 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.
args[x] = new char[strlen(str) + 1];
// Copy this into memory.