diff --git a/usr.sbin/lpr/chkprintcap/chkprintcap.c b/usr.sbin/lpr/chkprintcap/chkprintcap.c index 96fe4896fb2e..fab2239adbd2 100644 --- a/usr.sbin/lpr/chkprintcap/chkprintcap.c +++ b/usr.sbin/lpr/chkprintcap/chkprintcap.c @@ -113,8 +113,13 @@ main(int argc, char **argv) * the printcap file. */ skres = skim_printcap(pcap_fname, verbosity); - if (skres->fatalerr) - return (skres->fatalerr); + if (skres == NULL) { + problems = 1; + goto main_ret; + } else if (skres->fatalerr) { + problems = skres->fatalerr; + goto main_ret; + } /* * Now use the standard capability-db routines to check the values @@ -156,6 +161,9 @@ next: warnx("WARNING: but only found %d queues to process!", queuecnt); } + +main_ret: + free(pcap_fname); return (problems); } diff --git a/usr.sbin/lpr/chkprintcap/skimprintcap.c b/usr.sbin/lpr/chkprintcap/skimprintcap.c index da2828290b8b..34e61ceb8fb2 100644 --- a/usr.sbin/lpr/chkprintcap/skimprintcap.c +++ b/usr.sbin/lpr/chkprintcap/skimprintcap.c @@ -82,6 +82,8 @@ skim_printcap(const char *pcap_fname, int verbosity) enum {CMNT_LINE, ENTRY_LINE, TAB_LINE, TABERR_LINE} is_type, had_type; skinf = malloc(sizeof(struct skiminfo)); + if (skinf == NULL) + return (NULL); memset(skinf, 0, sizeof(struct skiminfo)); pc_file = fopen(pcap_fname, "r");