mirror of
https://github.com/github/codeql.git
synced 2026-05-03 12:45:27 +02:00
C++: Add support for 'data' in the query.
This commit is contained in:
@@ -5,4 +5,8 @@
|
||||
| test.cpp:178:37:178:41 | call to c_str | The underlying string object is destroyed after the call to 'c_str' returns. |
|
||||
| test.cpp:181:39:181:43 | call to c_str | The underlying string object is destroyed after the call to 'c_str' returns. |
|
||||
| test.cpp:183:37:183:41 | call to c_str | The underlying string object is destroyed after the call to 'c_str' returns. |
|
||||
| test.cpp:187:31:187:35 | call to c_str | The underlying string object is destroyed after the call to 'c_str' returns. |
|
||||
| test.cpp:187:34:187:37 | call to data | The underlying string object is destroyed after the call to 'data' returns. |
|
||||
| test.cpp:188:39:188:42 | call to data | The underlying string object is destroyed after the call to 'data' returns. |
|
||||
| test.cpp:189:44:189:47 | call to data | The underlying string object is destroyed after the call to 'data' returns. |
|
||||
| test.cpp:191:29:191:32 | call to data | The underlying string object is destroyed after the call to 'data' returns. |
|
||||
| test.cpp:193:31:193:35 | call to c_str | The underlying string object is destroyed after the call to 'c_str' returns. |
|
||||
|
||||
@@ -184,6 +184,12 @@ const char* test1(bool b1, bool b2) {
|
||||
|
||||
char c = std::string("hello").c_str()[0]; // GOOD
|
||||
|
||||
auto s6 = std::string("hello").data(); // BAD
|
||||
auto s7 = b1 ? std::string("hello").data() : ""; // BAD
|
||||
auto s8 = b2 ? "" : std::string("hello").data(); // BAD
|
||||
char* s9;
|
||||
s9 = std::string("hello").data(); // BAD
|
||||
|
||||
return std::string("hello").c_str(); // BAD
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user