Skip to content

Commit

Permalink
Merge pull request #5099 from afeher/drqs-145970933-string-insert-rep…
Browse files Browse the repository at this point in the history
…lace-fortifying

Drqs 145970933 string insert fortifying
  • Loading branch information
cppguru authored and GitHub Enterprise committed Nov 30, 2024
2 parents 411c813 + e0577f1 commit fe714ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 9 additions & 0 deletions groups/bsl/bslstl/bslstl_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,15 @@ class basic_string
const CHAR_TYPE *other,
size_type otherNumChars) const;

// NOT IMPLEMENTED

/// This method signature is defined as private, unimplemented, and (if
/// that is supported) deleted to avoid calls like `string.insert(0, 'x')`
/// to be picked up by the wrong insert function because the 0 converts
/// into a null pointer that is then treated as an iterator. If the intent
/// is to insert at the beginning, use `s.insert(s.begin(), 'x')`.
void insert(size_type zero, CHAR_TYPE) BSLS_KEYWORD_DELETED;

// INVARIANTS
BSLMF_ASSERT((bsl::is_same<CHAR_TYPE,
typename ALLOCATOR::value_type>::value));
Expand Down
10 changes: 5 additions & 5 deletions groups/bsl/bslstl/bslstl_string_test.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2476,7 +2476,7 @@ void TestDriver<TYPE, TRAITS, ALLOC>::testCase42()
}
}

// A brute-force search to see if the specified 'pattern' exists in the
// A brute-force search to see if the specified 'pattern' exists in the
// specified 'corpus'
template <class TYPE, class TRAITS>
bool containsOracle(bsl::basic_string_view<TYPE, TRAITS> pattern,
Expand All @@ -2490,7 +2490,7 @@ bool containsOracle(bsl::basic_string_view<TYPE, TRAITS> pattern,
if (pattern == corpus.substr(i, pattern.size()))
return true;
}
return false;
return false;
}

template <class TYPE, class TRAITS, class ALLOC>
Expand Down Expand Up @@ -2655,7 +2655,7 @@ void TestDriver<TYPE, TRAITS, ALLOC>::testCase41()
OBJ_INDEX == STR_INDEX;
const bool E_CH_RESULT = OBJ_LENGTH != 0 &&
OBJ_INDEX + OBJ_LENGTH - 1 == STR_INDEX;
const bool C_CH_RESULT = OBJ_LENGTH != 0 &&
const bool C_CH_RESULT = OBJ_LENGTH != 0 &&
bsl::find(X.begin(), X.end(), CH) != X.end();

Tam dam(defaultAllocator_p);
Expand Down Expand Up @@ -2801,7 +2801,7 @@ void TestDriver<TYPE, TRAITS, ALLOC>::testCase41()
: 'A' == OBJ_SPEC[OBJ_SPEC_LEN - 1];
const bool EXP_0_C = 0 == OBJ_SPEC_LEN
? false
: std::find(OBJ_SPEC,
: std::find(OBJ_SPEC,
OBJ_SPEC + OBJ_SPEC_LEN,
'0') != OBJ_SPEC + OBJ_SPEC_LEN;
const bool EXP_A_C = 0 == OBJ_SPEC_LEN
Expand Down Expand Up @@ -3442,7 +3442,7 @@ void TestDriver<TYPE, TRAITS, ALLOC>::testCase37()
nua->numBytesTotal(),
expNotUsedAllocTotal == nua->numBytesTotal());

ASSERTV(ty, LINE_L, LINE_R,
ASSERTV(ty, LINE_L, LINE_R,
ua == (XL + VWR).get_allocator().allocator());

// Reference providing non-modifiable access to `bsl::string`
Expand Down

0 comments on commit fe714ab

Please sign in to comment.