Last active
September 30, 2016 06:04
-
-
Save master-q/d96b31d9e048a2c74abc70cdbfb3de46 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <unistd.h> | |
#include <sys/types.h> | |
#define __infer_assert(E) \ | |
int *s = NULL; \ | |
if (!(E)) *s = 0xDEADBEEF; | |
int main() { | |
uid_t id; | |
id = getuid(); | |
__infer_assert(id != 0); | |
} |
This file contains hidden or 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
$ infer -- gcc -c assert1.c | |
Starting analysis (Infer version v0.8.1) | |
F. | |
Analyzed 1 file | |
Found 1 issue | |
assert1.c:11: error: NULL_DEREFERENCE | |
pointer s last assigned on line 11 could be null and is dereferenced at line 11, column 2 | |
9. uid_t id; | |
10. id = getuid(); | |
11. > __infer_assert(id != 0); | |
12. } | |
13. | |
Summary of the reports | |
NULL_DEREFERENCE: 1 |
This file contains hidden or 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
$ gcc assert1.c | |
$ ./a.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment