[Scummvm-git-logs] scummvm master -> 4eb00e965ade278bd2087b1c832c0c8c81194aee
bluegr
bluegr at gmail.com
Wed Jul 21 21:12:18 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4eb00e965a SYMBIAN: Avoid deleting argv if no command line arguments have been set
Commit: 4eb00e965ade278bd2087b1c832c0c8c81194aee
https://github.com/scummvm/scummvm/commit/4eb00e965ade278bd2087b1c832c0c8c81194aee
Author: Fiodar (fedor4ever at users.noreply.github.com)
Date: 2021-07-22T00:12:16+03:00
Commit Message:
SYMBIAN: Avoid deleting argv if no command line arguments have been set
Also apply style fixes from #3170.
Changed paths:
backends/platform/symbian/src/SymbianMain.cpp
diff --git a/backends/platform/symbian/src/SymbianMain.cpp b/backends/platform/symbian/src/SymbianMain.cpp
index cc02637b4f..c7c0cb51f2 100644
--- a/backends/platform/symbian/src/SymbianMain.cpp
+++ b/backends/platform/symbian/src/SymbianMain.cpp
@@ -21,7 +21,7 @@
*/
-#include <bacline.h> // CCommandLineArguments
+#include <bacline.h> // CCommandLineArguments
#include "backends/platform/symbian/src/portdefs.h"
#include "base/main.h"
@@ -29,32 +29,31 @@
extern "C"
{
-// Include the snprintf and vsnprintf implementations as 'C' code
+// Include the snprintf and vsnprintf implementations as 'C' code.
#include "vsnprintf.h"
}
-// Symbian SDL_Main implementation
-// Redirects standard io, creates Symbian specific SDL backend (inherited from main SDL)
+// Symbian SDL_Main implementation.
+// Redirects standard io, creates Symbian specific SDL backend (inherited from main SDL).
int main(int argc, char *argv[]) {
- //
+
// Set up redirects for stdout/stderr under Symbian.
// Code copied from SDL_main.
- //
- // Symbian does not like any output to the console through any *print* function
- char STDOUT_FILE[256], STDERR_FILE[256]; // shhh, don't tell anybody :)
+ // Symbian does not like any output to the console through any *print* function.
+ char STDOUT_FILE[256], STDERR_FILE[256]; // Shhh, don't tell anybody :)
strcpy(STDOUT_FILE, Symbian::GetExecutablePath());
strcpy(STDERR_FILE, Symbian::GetExecutablePath());
strcat(STDOUT_FILE, "scummvm.stdout.txt");
strcat(STDERR_FILE, "scummvm.stderr.txt");
- /* Flush the output in case anything is queued */
+ // Flush the output in case anything is queued.
fclose(stdout);
fclose(stderr);
- /* Redirect standard input and standard output */
+ // Redirect standard input and standard output.
FILE *newfp = freopen(STDOUT_FILE, "w", stdout);
- if (newfp == NULL) { /* This happens on NT */
+ if (newfp == NULL) { // This happens on NT.
#if !defined(stdout)
stdout = fopen(STDOUT_FILE, "w");
#else
@@ -65,7 +64,7 @@ int main(int argc, char *argv[]) {
#endif
}
newfp = freopen(STDERR_FILE, "w", stderr);
- if (newfp == NULL) { /* This happens on NT */
+ if (newfp == NULL) { // This happens on NT.
#if !defined(stderr)
stderr = fopen(STDERR_FILE, "w");
#else
@@ -75,34 +74,34 @@ int main(int argc, char *argv[]) {
}
#endif
}
- setbuf(stderr, NULL); /* No buffering */
+ setbuf(stderr, NULL); // No buffering.
- // Create our OSystem instance
+ // Create our OSystem instance.
g_system = new OSystem_SDL_Symbian();
assert(g_system);
- // Pre initialize the backend
+ // Pre initialize the backend.
g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
#endif
- // catch input params and pass to argv/argc
+ // Catch input params and pass to argv/argc.
CCommandLineArguments *cmdline = CCommandLineArguments::NewL();
if (!cmdline) {
error("Failure to alloc CCommandLineArguments!");
return -1;
}
-
+
argc = cmdline->Count();
if (argc > 1) {
debug("console arg count by CCommandLineArguments: %d", argc);
argv = new char* [argc];
- HBufC8 *buf = HBufC8::NewMax(20); //this suffice for most cases
+ HBufC8 *buf = HBufC8::NewMax(20); // This should suffice for most cases.
for (TInt i = 0; i < argc; ++i) {
TPtrC arg = cmdline->Arg(i);
- argv[i] = new char[arg.Length() + 1](); //hold zero terminated string
+ argv[i] = new char[arg.Length() + 1](); // Hold zero terminated string.
if (arg.Length() > buf->Length())
buf->ReAlloc(arg.Length());
@@ -117,14 +116,16 @@ int main(int argc, char *argv[]) {
// Invoke the actual ScummVM main entry point:
int res = scummvm_main(argc, argv);
- // clear argv
- for (TInt i = 0; i < argc; ++i) {
- delete[] argv[i];
+ // Clear argv.
+ if (argc > 1) { //avoid multiple User 42 panics at exit
+ for (TInt i = 0; i < argc; ++i) {
+ delete[] argv[i];
+ }
+ delete[] argv;
}
- delete[] argv;
delete cmdline;
- // Free OSystem
+ // Free OSystem.
g_system->destroy();
return res;
More information about the Scummvm-git-logs
mailing list