hello_invalid_free2.c 366 Bytes
Newer Older
Adam Blank's avatar
Adam Blank committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
    char *x = malloc(100);
    strcpy(x, "Hello World!");
    printf("%s\n", x);
    free(x + 1);
}

// 20

// stdout: Hello World!

// stderr: Invalid free(): 0x100001f9d is not an allocation
// stderr: at bin/hello_invalid_free2(main+0x53)
// stderr: main
// stderr: hello_invalid_free2.c:9