mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
CPP: Clean up / normalize some test code.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
|
||||
char *Xstrdup(const char *string);
|
||||
void abort();
|
||||
void abort(void);
|
||||
struct FILE;
|
||||
char *fgets(char *str, int num, FILE *stream);
|
||||
char *fgets(char *s, int n, FILE *stream);
|
||||
int ignore_return_value();
|
||||
#define IGNORE_RETURN_VALUE() ignore_return_value()
|
||||
void myIgnoreReturnValue();
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
| test.cpp:22:3:22:26 | return ... | Return value may contain a dangling pointer to $@. | test.cpp:21:24:21:37 | call to string | this local std::string |
|
||||
| test.cpp:30:3:30:44 | return ... | Return value may contain a dangling pointer to $@. | test.cpp:30:10:30:35 | call to string | this local std::string |
|
||||
| test.cpp:43:3:43:42 | return ... | Return value may contain a dangling pointer to $@. | test.cpp:42:22:42:35 | call to string | this local std::string |
|
||||
| test.cpp:24:3:24:26 | return ... | Return value may contain a dangling pointer to $@. | test.cpp:23:24:23:37 | call to basic_string | this local std::string |
|
||||
| test.cpp:32:3:32:44 | return ... | Return value may contain a dangling pointer to $@. | test.cpp:32:10:32:35 | call to basic_string | this local std::string |
|
||||
| test.cpp:45:3:45:42 | return ... | Return value may contain a dangling pointer to $@. | test.cpp:44:22:44:35 | call to basic_string | this local std::string |
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
extern "C" {
|
||||
char *strdup(const char *s);
|
||||
void free (void* ptr);
|
||||
}
|
||||
|
||||
namespace std {
|
||||
// We are not allowed to include <string> in the test file,
|
||||
// so this is an approximation of the std::string class.
|
||||
class string {
|
||||
char* str_;
|
||||
template<class charT> struct char_traits;
|
||||
|
||||
template <class T> class allocator {
|
||||
public:
|
||||
string(const char* str) : str_(strdup(str)) {}
|
||||
~string() { free(str_); }
|
||||
|
||||
const char* c_str() const noexcept { return str_; }
|
||||
allocator() throw();
|
||||
};
|
||||
|
||||
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
class basic_string {
|
||||
public:
|
||||
explicit basic_string(const Allocator& a = Allocator());
|
||||
basic_string(const charT* s, const Allocator& a = Allocator());
|
||||
|
||||
const charT* c_str() const;
|
||||
};
|
||||
|
||||
typedef basic_string<char> string;
|
||||
}
|
||||
|
||||
const char* bad000() {
|
||||
|
||||
Reference in New Issue
Block a user