Skip to content
Snippets Groups Projects
Commit 7913e613 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #6000: fix memory leak of args object

parent c70912e0
Branches
Tags
No related merge requests found
......@@ -33,6 +33,7 @@
#include <libintl.h>
#include <cstring>
#include <iostream>
#include <memory> // for auto_ptr
#include <string>
#include <dirent.h>
#include <sys/stat.h>
......@@ -71,7 +72,10 @@ main (int argc, char **argv)
Logger::setConsoleLog (false);
Logger::setDebugMode (false);
CommandOptionParse * args = makeCommandOptionParse (argc, argv, "");
// makeCommandOptionParse allocates the object with operator new, so
// auto_ptr is fine in this context.
// TODO: This should eventually be replaced with std::unique_ptr for C++0x
std::auto_ptr<CommandOptionParse> args(makeCommandOptionParse (argc, argv, ""));
printf ("SFLphone Daemon %s, by Savoir-Faire Linux 2004-2011\n", VERSION);
printf ("http://www.sflphone.org/\n");
......@@ -80,8 +84,7 @@ main (int argc, char **argv)
std::cerr << args->printUsage();
::exit (0);
}
if (args->argsHaveError()) {
else if (args->argsHaveError()) {
std::cerr << args->printErrors();
std::cerr << args->printUsage();
::exit (1);
......@@ -97,8 +100,6 @@ main (int argc, char **argv)
Logger::setDebugMode (true);
}
delete args;
FILE *fp;
char homepid[128];
char sfldir[128];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment