CPP: Additional test case.

This commit is contained in:
Geoffrey White
2019-11-22 15:01:04 +00:00
parent 5c855fc925
commit bbe6a1aa76

View File

@@ -14,13 +14,16 @@ namespace std
template <class T> class allocator {
public:
allocator() throw();
typedef size_t size_type;
};
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_string {
public:
typedef typename Allocator::size_type size_type;
explicit basic_string(const Allocator& a = Allocator());
basic_string(const charT* s, const Allocator& a = Allocator());
basic_string(const charT* s, size_type n, const Allocator& a = Allocator());
const charT* c_str() const;
};
@@ -36,3 +39,12 @@ void bad1(char *str) {
std::string str2(buffer);
free(buffer);
}
void good1(char *str) {
// GOOD --- copy does not overrun due to size limit
char *buffer = (char *)malloc(strlen(str));
std::string str2(buffer, strlen(str));
free(buffer);
}