It is trivial to fully cleanup memory on all the error paths in
named-rrchecker, many of which are triggered by bad user input.
This involves freeing lex and mctx if they exist when fatal is
called.
exit(0);
}
+static void
+cleanup(void) {
+ if (lex != NULL) {
+ isc_lex_close(lex);
+ isc_lex_destroy(&lex);
+ }
+ if (mctx != NULL) {
+ isc_mem_destroy(&mctx);
+ }
+}
+
noreturn static void
fatal(const char *format, ...);
vfprintf(stderr, format, args);
va_end(args);
fputc('\n', stderr);
+ cleanup();
exit(1);
}
fflush(stdout);
}
- isc_lex_close(lex);
- isc_lex_destroy(&lex);
- isc_mem_destroy(&mctx);
+ cleanup();
return (0);
}