Skip to content

Commit 8e86715

Browse files
ice909dengbo11
authored andcommitted
fix: prevent crash in prune command after loop exit
Added missing return statements after loop.exit() calls in the prune command to prevent function execution from continuing after exit is called. This fixes a crash that occurred when the function continued executing code after requesting the event loop to exit, potentially accessing invalid memory.
1 parent c4038b6 commit 8e86715

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • libs/linglong/src/linglong/cli

libs/linglong/src/linglong/cli/cli.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,11 +1513,13 @@ int Cli::prune([[maybe_unused]] CLI::App *subcommand)
15131513
if (!ret) {
15141514
this->printer.printErr(ret.error());
15151515
loop.exit(-1);
1516+
return;
15161517
}
15171518

15181519
if (!ret->packages) {
15191520
this->printer.printErr(LINGLONG_ERRV("No packages to prune."));
15201521
loop.exit(0);
1522+
return;
15211523
}
15221524

15231525
this->printer.printPruneResult(*ret->packages);

0 commit comments

Comments
 (0)