From a4bab45fcdbf8de972361e5e384078d9283c280a Mon Sep 17 00:00:00 2001 From: Radu Iulian Date: Mon, 18 Jul 2022 21:03:42 +0300 Subject: [PATCH 1/3] get_part_by_name doesn't crash on nonexistent keys --- include/crow/multipart.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/crow/multipart.h b/include/crow/multipart.h index a05ffd3e3..f88d2f2fb 100644 --- a/include/crow/multipart.h +++ b/include/crow/multipart.h @@ -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**) From b89d13ac3bfec4dda104401768b0a7dddf5708e3 Mon Sep 17 00:00:00 2001 From: Radu Iulian Date: Mon, 18 Jul 2022 21:42:14 +0300 Subject: [PATCH 2/3] fixed formatting --- include/crow/multipart.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/crow/multipart.h b/include/crow/multipart.h index f88d2f2fb..9efa89cf6 100644 --- a/include/crow/multipart.h +++ b/include/crow/multipart.h @@ -89,7 +89,7 @@ namespace crow if(result != part_map.end()) return result->second; else - return {}; + return {}; } /// Represent all parts as a string (**does not include message headers**) From 31160579ea97d1e84111da39da51b9adabfd9f22 Mon Sep 17 00:00:00 2001 From: Iulian Radu <64871927+Iuliean@users.noreply.github.com> Date: Mon, 18 Jul 2022 22:08:44 +0300 Subject: [PATCH 3/3] Update multipart.h format --- include/crow/multipart.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/crow/multipart.h b/include/crow/multipart.h index 9efa89cf6..f7b6c24dd 100644 --- a/include/crow/multipart.h +++ b/include/crow/multipart.h @@ -86,7 +86,7 @@ namespace crow part get_part_by_name(const std::string& name) { mp_map::iterator result = part_map.find(name); - if(result != part_map.end()) + if (result != part_map.end()) return result->second; else return {};