diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-06-01 10:47:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-01 10:47:37 +0200 |
commit | 59b524ae4c1d81150d88fa9618f8f33c1cf6b6ea (patch) | |
tree | 50530c40716fa3e5a45c403f106b407e120757f1 /tests/test_main.cpp | |
parent | 5ec8920cde0cf5aafda59dfda335772acf3fcd15 (diff) | |
parent | f8e34209afbf5c862c9638c8029dbfc1be67a30c (diff) |
Merge pull request #49067 from JFonS/fix_gcc_warnings
Fix some warnings raised by GCC-11.1
Diffstat (limited to 'tests/test_main.cpp')
-rw-r--r-- | tests/test_main.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 67fb38aa86..54327caf3d 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -121,24 +121,27 @@ int test_main(int argc, char *argv[]) { test_args.push_back(arg); } } - // Convert Godot command line arguments back to standard arguments. - char **doctest_args = new char *[test_args.size()]; - for (int x = 0; x < test_args.size(); x++) { - // Operation to convert Godot string to non wchar string. - CharString cs = test_args[x].utf8(); - const char *str = cs.get_data(); - // Allocate the string copy. - doctest_args[x] = new char[strlen(str) + 1]; - // Copy this into memory. - memcpy(doctest_args[x], str, strlen(str) + 1); - } - test_context.applyCommandLine(test_args.size(), doctest_args); + if (test_args.size() > 0) { + // Convert Godot command line arguments back to standard arguments. + char **doctest_args = new char *[test_args.size()]; + for (int x = 0; x < test_args.size(); x++) { + // Operation to convert Godot string to non wchar string. + CharString cs = test_args[x].utf8(); + const char *str = cs.get_data(); + // Allocate the string copy. + doctest_args[x] = new char[strlen(str) + 1]; + // Copy this into memory. + memcpy(doctest_args[x], str, strlen(str) + 1); + } + + test_context.applyCommandLine(test_args.size(), doctest_args); - for (int x = 0; x < test_args.size(); x++) { - delete[] doctest_args[x]; + for (int x = 0; x < test_args.size(); x++) { + delete[] doctest_args[x]; + } + delete[] doctest_args; } - delete[] doctest_args; return test_context.run(); } |