Skip to content

Commit

Permalink
fix potential memory leak in example
Browse files Browse the repository at this point in the history
  • Loading branch information
Tectu committed Aug 3, 2022
1 parent c38c594 commit 2d48534
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/basic/car.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class car :
manufacturer = c.get_value<std::string>("manufacturer").value_or("");
model = c.get_value<std::string>("model").value_or("");
year_of_construction = c.get_value<int>("year_of_construction").value_or(0);
color.from_container(*c.get_value<gpds::container*>("color").value_or(new gpds::container));

if (const gpds::container* c_color = c.get_value<gpds::container*>("color").value_or(nullptr); c_color)
color.from_container(*c_color);
}
};

0 comments on commit 2d48534

Please sign in to comment.