mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-15 20:05:13 +02:00
17 lines
488 B
C
17 lines
488 B
C
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
/* Close before the loop, then use inside the loop body.
|
||
|
|
The back-edge means the use node joins CLOSED (first iter)
|
||
|
|
with CLOSED (back-edge, still CLOSED). The converged state
|
||
|
|
at the fread call is CLOSED → use-after-close.
|
||
|
|
Expected: state-use-after-close. */
|
||
|
|
void loop_use_after_close(void) {
|
||
|
|
FILE *f = fopen("data.txt", "r");
|
||
|
|
fclose(f);
|
||
|
|
char buf[256];
|
||
|
|
int i;
|
||
|
|
for (i = 0; i < 10; i++) {
|
||
|
|
fread(buf, 1, sizeof(buf), f);
|
||
|
|
}
|
||
|
|
}
|