Add files via upload

This commit is contained in:
ihsinme
2021-04-25 22:25:17 +03:00
committed by GitHub
parent f2b2300da9
commit c1d125b378
3 changed files with 24 additions and 0 deletions

View File

@@ -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. |

View File

@@ -0,0 +1 @@
experimental/Security/CWE/CWE-415/DoubleFree.ql

View File

@@ -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);
}