...
Code Block | ||
---|---|---|
| ||
void cleanup(void) { /* deleteDelete temporary files, restore consistent state, etc. */ } int main(void) { if (atexit(cleanup) != 0) { /* Handle error */ } /* ... */ assert(/* something bad didn't happen */); /* ... */ } |
...
Code Block | ||
---|---|---|
| ||
void cleanup(void) { /* delete temporary files, restore consistent state, etc */ } int main(void) { if (atexit(cleanup) != 0) { /* Handle error */ } /* ... */ if (/* something bad happened */) { exit(EXIT_FAILURE); } /* ... */ } |
Risk
...
Assessment
Unsafe usage of abort()
may leave files written in an inconsistent state. It may also leave sensitive temporary files on the file system.
...