[CODE HEALTH] Prevent std::out_of_range escaping noexcept substr callers - #4562
denizariyan wants to merge 1 commit into
Conversation
| static std::string default_str = ""; | ||
| return default_str; | ||
| } | ||
| static nostd::string_view GetDefaultKeyOrValue() noexcept { return ""; } |
There was a problem hiding this comment.
I tried looking for context on why this was implemented like this in the git/pr history and it was added as part of a commit mentioning buffer overflow but this is not related to any buffer overflow. c9cbb1a
As far as I see there is no benefit of having a static string here, hence replaced with a str literal to prevent an additional bad_alloc potential on the same noexcept caller that was reported after fixing the other issue
There was a problem hiding this comment.
I also chose not to mark this function noexcept (was marked initially in this PR). Since C++17 the exception specification is part of the function type, so adding it would change the type of a pre-existing public function without any benefits in this case
4aca959 to
3271383
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4562 +/- ##
==========================================
+ Coverage 86.45% 86.48% +0.03%
==========================================
Files 525 525
Lines 20450 20455 +5
==========================================
+ Hits 17679 17689 +10
+ Misses 2771 2766 -5
🚀 New features to boost your workflow:
|
Fixes # (issue)
Changes
Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes