Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_part_by_name doesn't crash on nonexistent keys #501

Merged
merged 3 commits into from
Jul 18, 2022
Merged

get_part_by_name doesn't crash on nonexistent keys #501

merged 3 commits into from
Jul 18, 2022

Conversation

Iuliean
Copy link
Contributor

@Iuliean Iuliean commented Jul 18, 2022

This no longer causes a segfault if the key that is being searched for does not exist

@crow-clang-format
Copy link

--- include/crow/multipart.h	(before formatting)
+++ include/crow/multipart.h	(after formatting)
@@ -86,10 +86,10 @@
             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 {}; 
+                    return {};
             }
 
             /// Represent all parts as a string (**does not include message headers**)

@The-EDev
Copy link
Member

Thank you for implementing this, sorry I didn't give you instructions in time. Could you please make a new commit fixing the formatting errors pointed out by the bot? Thanks again!

@Iuliean
Copy link
Contributor Author

Iuliean commented Jul 18, 2022

No problem

I made the commit. is it ok ?

@The-EDev
Copy link
Member

Everything seems to be alright, I'll merge it as soon as the tests are done running.

@Iuliean
Copy link
Contributor Author

Iuliean commented Jul 18, 2022

Nice

@crow-clang-format
Copy link

--- include/crow/multipart.h	(before formatting)
+++ include/crow/multipart.h	(after formatting)
@@ -86,7 +86,7 @@
             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 {};

@The-EDev The-EDev merged commit 777b2db into CrowCpp:master Jul 18, 2022
@Iuliean Iuliean deleted the get_part_by_name_fix branch July 29, 2022 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

message::get_part_by_name causes segfault if the key it searches for does not exist
2 participants