Skip to content

Commit

Permalink
Fix memleaks in help/version (LMMS#7423)
Browse files Browse the repository at this point in the history
* Fix memleaks in help/version

These memory leaks caused help and version to crash at the end, due to
rpmalloc's memleak detection.
  • Loading branch information
JohannesLorenz authored Aug 4, 2024
1 parent 1f224ad commit 735e483
Showing 1 changed file with 52 additions and 54 deletions.
106 changes: 52 additions & 54 deletions src/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,57 @@ int main( int argc, char * * argv )
{
using namespace lmms;

bool coreOnly = false;
bool fullscreen = true;
bool exitAfterImport = false;
bool allowRoot = false;
bool renderLoop = false;
bool renderTracks = false;
QString fileToLoad, fileToImport, renderOut, profilerOutputFile, configFile;

// first of two command-line parsing stages
for (int i = 1; i < argc; ++i)
{
QString arg = argv[i];

if (arg == "--help" || arg == "-h")
{
printHelp();
return EXIT_SUCCESS;
}
else if (arg == "--version" || arg == "-v")
{
printVersion(argv[0]);
return EXIT_SUCCESS;
}
else if (arg == "render" || arg == "--render" || arg == "-r" )
{
coreOnly = true;
}
else if (arg == "rendertracks" || arg == "--rendertracks")
{
coreOnly = true;
renderTracks = true;
}
else if (arg == "--allowroot")
{
allowRoot = true;
}
else if (arg == "--geometry" || arg == "-geometry")
{
if (arg == "--geometry")
{
// Delete the first "-" so Qt recognize the option
strcpy(argv[i], "-geometry");
}
// option -geometry is filtered by Qt later,
// so we need to check its presence now to
// determine, if the application should run in
// fullscreen mode (default, no -geometry given).
fullscreen = false;
}
}

#ifdef LMMS_DEBUG_FPE
// Enable exceptions for certain floating point results
// FE_UNDERFLOW is disabled for the time being
Expand Down Expand Up @@ -314,49 +365,6 @@ int main( int argc, char * * argv )

disable_denormals();

bool coreOnly = false;
bool fullscreen = true;
bool exitAfterImport = false;
bool allowRoot = false;
bool renderLoop = false;
bool renderTracks = false;
QString fileToLoad, fileToImport, renderOut, profilerOutputFile, configFile;

// first of two command-line parsing stages
for( int i = 1; i < argc; ++i )
{
QString arg = argv[i];

if( arg == "--help" || arg == "-h" ||
arg == "--version" || arg == "-v" ||
arg == "render" || arg == "--render" || arg == "-r" )
{
coreOnly = true;
}
else if( arg == "rendertracks" || arg == "--rendertracks" )
{
coreOnly = true;
renderTracks = true;
}
else if( arg == "--allowroot" )
{
allowRoot = true;
}
else if( arg == "--geometry" || arg == "-geometry")
{
if( arg == "--geometry" )
{
// Delete the first "-" so Qt recognize the option
strcpy(argv[i], "-geometry");
}
// option -geometry is filtered by Qt later,
// so we need to check its presence now to
// determine, if the application should run in
// fullscreen mode (default, no -geometry given).
fullscreen = false;
}
}

#if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BUILD_HAIKU)
if ( ( getuid() == 0 || geteuid() == 0 ) && !allowRoot )
{
Expand All @@ -382,17 +390,7 @@ int main( int argc, char * * argv )
{
QString arg = argv[i];

if( arg == "--version" || arg == "-v" )
{
printVersion( argv[0] );
return EXIT_SUCCESS;
}
else if( arg == "--help" || arg == "-h" )
{
printHelp();
return EXIT_SUCCESS;
}
else if( arg == "upgrade" || arg == "--upgrade" || arg == "-u")
if (arg == "upgrade" || arg == "--upgrade" || arg == "-u")
{
++i;

Expand Down

0 comments on commit 735e483

Please sign in to comment.