Created
April 24, 2022 10:51
-
-
Save jiachen247/82c6d50270347107b56e459e89eca628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "HeaderFile.h" | |
void clangGood () { | |
// simple use after free | |
char *buf; | |
buf = (char*) malloc (50 * sizeof(char)); | |
strcpy(buf, "Hello world!!"); | |
free(buf); | |
char *c = buf; /*ERROR:Invalid memory access to already freed area*/ | |
} | |
int echo(flag) { | |
int ret; | |
if (flag ==0) | |
ret = 0; | |
else | |
ret=1; | |
return ret; | |
} | |
void clangBad () { | |
// memleak due to path sens (interproc in conditional) | |
double *dptr= (double*) malloc(5*sizeof(double)); | |
if (echo(1) == 1) { | |
free(dptr); | |
} | |
} | |
int *returnNullPointer (void) | |
{ | |
return (NULL); | |
} | |
int inferGood() { | |
// null deference across interproc calls | |
int *p = returnNullPointer(); | |
return *p; | |
} | |
void inferBad() { | |
// simple memleak | |
double *dptr= (double*) malloc(5*sizeof(double)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment