Skip to content

Commit

Permalink
Merge pull request #501 from Iuliean/get_part_by_name_fix
Browse files Browse the repository at this point in the history
get_part_by_name doesn't crash on nonexistent keys
  • Loading branch information
The-EDev authored Jul 18, 2022
2 parents e662a90 + 3116057 commit 777b2db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/crow/multipart.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ namespace crow

part get_part_by_name(const std::string& name)
{
return part_map.find(name)->second;
mp_map::iterator result = part_map.find(name);
if (result != part_map.end())
return result->second;
else
return {};
}

/// Represent all parts as a string (**does not include message headers**)
Expand Down

0 comments on commit 777b2db

Please sign in to comment.