Skip to content

Commit

Permalink
Avoid memory leak when frontline parsers fails to separate
Browse files Browse the repository at this point in the history
  • Loading branch information
jemoreira committed Oct 14, 2024
1 parent ef72c8b commit 6021a97
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions base/cvd/cuttlefish/host/commands/cvd/frontline_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "host/commands/cvd/frontline_parser.h"

#include <memory>
#include <vector>

#include <android-base/file.h>
Expand Down Expand Up @@ -51,11 +52,11 @@ Result<cvd_common::Args> ExtractCvdArgs(cvd_common::Args& args) {
Result<std::unique_ptr<FrontlineParser>> FrontlineParser::Parse(
ParserParam param) {
CF_EXPECT(!param.all_args.empty());
FrontlineParser* frontline_parser = new FrontlineParser(param);
std::unique_ptr<FrontlineParser> frontline_parser(new FrontlineParser(param));
CF_EXPECT(frontline_parser != nullptr,
"Memory allocation for FrontlineParser failed.");
CF_EXPECT(frontline_parser->Separate());
return std::unique_ptr<FrontlineParser>(frontline_parser);
return frontline_parser;
}

FrontlineParser::FrontlineParser(const ParserParam& param)
Expand Down

0 comments on commit 6021a97

Please sign in to comment.