Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ffcccc
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
bgColor#ccccff
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.

...