We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 155f750 commit 9afd166Copy full SHA for 9afd166
3 files changed
samples/memleak/bad.c
@@ -1,9 +1,11 @@
1
#include <stdlib.h>
2
int main()
3
{
4
- int result;
+ int result = 0;
5
char *a = malloc(10);
6
- a[0] = 0;
7
- result = a[0];
+ if (a) {
+ a[0] = 0;
8
+ result = a[0];
9
+ }
10
return result;
11
}
samples/memleak/good.c
@@ -1,10 +1,12 @@
- free(a);
+ free(a);
12
samples/memleak/out.txt
@@ -1,3 +1,3 @@
-samples\memleak\bad.c:8:5: error: Memory leak: a [memleak]
+samples\memleak\bad.c:10:5: error: Memory leak: a [memleak]
^
0 commit comments