mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Add files via upload
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
| test.c:9:8:9:10 | buf | This pointer may be cleared again later. |
|
||||
| test.c:19:26:19:29 | buf1 | This pointer may be cleared again later. |
|
||||
@@ -0,0 +1 @@
|
||||
experimental/Security/CWE/CWE-415/DoubleFree.ql
|
||||
@@ -0,0 +1,21 @@
|
||||
typedef unsigned long size_t;
|
||||
void *malloc(size_t size);
|
||||
void free(void *ptr);
|
||||
|
||||
void workFunction_0(char *s) {
|
||||
int intSize = 10;
|
||||
char *buf;
|
||||
buf = (char *) malloc(intSize);
|
||||
free(buf); // BAD
|
||||
if(buf) free(buf);
|
||||
}
|
||||
void workFunction_1(char *s) {
|
||||
int intSize = 10;
|
||||
char *buf;
|
||||
char *buf1;
|
||||
buf = (char *) malloc(intSize);
|
||||
buf1 = (char *) realloc(buf,intSize*2);
|
||||
if(buf) free(buf); // GOOD
|
||||
buf = (char *) realloc(buf1,intSize*4); // BAD
|
||||
free(buf1);
|
||||
}
|
||||
Reference in New Issue
Block a user