mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Merge pull request #5565 from geoffw0/avrule79
C++: Test strdup with AV rule 79
This commit is contained in:
@@ -18,9 +18,10 @@
|
||||
| NoDestructor.cpp:23:3:23:20 | ... = ... | Resource n is acquired by class MyClass5 but not released anywhere in this class. |
|
||||
| PlacementNew.cpp:36:3:36:36 | ... = ... | Resource p1 is acquired by class MyTestForPlacementNew but not released anywhere in this class. |
|
||||
| SelfRegistering.cpp:25:3:25:24 | ... = ... | Resource side is acquired by class MyOwner but not released anywhere in this class. |
|
||||
| Variants.cpp:25:3:25:13 | ... = ... | Resource f is acquired by class MyClass4 but not released anywhere in this class. |
|
||||
| Variants.cpp:65:3:65:17 | ... = ... | Resource a is acquired by class MyClass6 but not released anywhere in this class. |
|
||||
| Variants.cpp:66:3:66:36 | ... = ... | Resource b is acquired by class MyClass6 but not released anywhere in this class. |
|
||||
| Variants.cpp:67:3:67:41 | ... = ... | Resource c is acquired by class MyClass6 but not released anywhere in this class. |
|
||||
| Variants.cpp:26:3:26:13 | ... = ... | Resource f is acquired by class MyClass4 but not released anywhere in this class. |
|
||||
| Variants.cpp:69:3:69:17 | ... = ... | Resource a is acquired by class MyClass6 but not released anywhere in this class. |
|
||||
| Variants.cpp:70:3:70:36 | ... = ... | Resource b is acquired by class MyClass6 but not released anywhere in this class. |
|
||||
| Variants.cpp:71:3:71:41 | ... = ... | Resource c is acquired by class MyClass6 but not released anywhere in this class. |
|
||||
| Variants.cpp:72:3:72:22 | ... = ... | Resource d is acquired by class MyClass6 but not released anywhere in this class. |
|
||||
| Wrapped.cpp:46:3:46:22 | ... = ... | Resource ptr2 is acquired by class Wrapped2 but not released anywhere in this class. |
|
||||
| Wrapped.cpp:59:3:59:22 | ... = ... | Resource ptr4 is acquired by class Wrapped2 but not released anywhere in this class. |
|
||||
|
||||
@@ -5,6 +5,7 @@ void *malloc(size_t size);
|
||||
void *calloc(size_t nmemb, size_t size);
|
||||
void *realloc(void *ptr, size_t size);
|
||||
void free(void* ptr);
|
||||
char *strdup(const char *s1);
|
||||
|
||||
int *ID(int *x)
|
||||
{
|
||||
@@ -45,6 +46,7 @@ public:
|
||||
a = new int[10]; // GOOD
|
||||
b = (int *)calloc(10, sizeof(int)); // GOOD
|
||||
c = (int *)realloc(0, 10 * sizeof(int)); // GOOD
|
||||
d = strdup("string");
|
||||
}
|
||||
|
||||
~MyClass5()
|
||||
@@ -52,9 +54,11 @@ public:
|
||||
delete [] a;
|
||||
free(b);
|
||||
free(c);
|
||||
free(d);
|
||||
}
|
||||
|
||||
int *a, *b, *c;
|
||||
char *d;
|
||||
};
|
||||
|
||||
class MyClass6
|
||||
@@ -65,6 +69,7 @@ public:
|
||||
a = new int[10]; // BAD
|
||||
b = (int *)calloc(10, sizeof(int)); // BAD
|
||||
c = (int *)realloc(0, 10 * sizeof(int)); // BAD
|
||||
d = strdup("string"); // BAD
|
||||
}
|
||||
|
||||
~MyClass6()
|
||||
@@ -72,6 +77,7 @@ public:
|
||||
}
|
||||
|
||||
int *a, *b, *c;
|
||||
char *d;
|
||||
};
|
||||
|
||||
class MyClass7
|
||||
|
||||
Reference in New Issue
Block a user