From a0242ada35aa0eb3c776d837b98713a1921828a1 Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 18 Apr 2017 01:45:33 +0000 Subject: [PATCH] free(NULL) is ok so use it; from Michael W. Bombardieri --- usr.bin/vi/cl/cl_screen.c | 44 +++++++++++++------------------------ usr.bin/vi/common/cut.c | 5 ++--- usr.bin/vi/common/exf.c | 34 ++++++++++------------------ usr.bin/vi/common/key.c | 5 ++--- usr.bin/vi/common/log.c | 8 +++---- usr.bin/vi/common/main.c | 14 +++++------- usr.bin/vi/common/options.c | 8 +++---- usr.bin/vi/common/screen.c | 17 +++++--------- usr.bin/vi/common/seq.c | 23 +++++++------------ usr.bin/vi/ex/ex_bang.c | 5 ++--- usr.bin/vi/ex/ex_init.c | 9 +++----- usr.bin/vi/ex/ex_read.c | 5 ++--- usr.bin/vi/ex/ex_script.c | 5 ++--- usr.bin/vi/ex/ex_subst.c | 17 +++++--------- usr.bin/vi/ex/ex_tag.c | 14 +++++------- usr.bin/vi/vi/v_init.c | 16 +++++--------- usr.bin/vi/vi/v_paragraph.c | 5 ++--- usr.bin/vi/vi/vi.c | 8 +++---- usr.bin/vi/vi/vs_msg.c | 5 ++--- 19 files changed, 88 insertions(+), 159 deletions(-) diff --git a/usr.bin/vi/cl/cl_screen.c b/usr.bin/vi/cl/cl_screen.c index 6f75e4bc61d..c1f77ed8032 100644 --- a/usr.bin/vi/cl/cl_screen.c +++ b/usr.bin/vi/cl/cl_screen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cl_screen.c,v 1.27 2016/05/28 18:30:35 martijn Exp $ */ +/* $OpenBSD: cl_screen.c,v 1.28 2017/04/18 01:45:33 deraadt Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -434,14 +434,10 @@ cl_ex_init(SCR *sp) /* Enter_standout_mode and exit_standout_mode are paired. */ if (clp->smso == NULL || clp->rmso == NULL) { - if (clp->smso != NULL) { - free(clp->smso); - clp->smso = NULL; - } - if (clp->rmso != NULL) { - free(clp->rmso); - clp->rmso = NULL; - } + free(clp->smso); + clp->smso = NULL; + free(clp->rmso); + clp->rmso = NULL; } /* @@ -515,26 +511,16 @@ cl_getcap(SCR *sp, char *name, char **elementp) static void cl_freecap(CL_PRIVATE *clp) { - if (clp->el != NULL) { - free(clp->el); - clp->el = NULL; - } - if (clp->cup != NULL) { - free(clp->cup); - clp->cup = NULL; - } - if (clp->cuu1 != NULL) { - free(clp->cuu1); - clp->cuu1 = NULL; - } - if (clp->rmso != NULL) { - free(clp->rmso); - clp->rmso = NULL; - } - if (clp->smso != NULL) { - free(clp->smso); - clp->smso = NULL; - } + free(clp->el); + clp->el = NULL; + free(clp->cup); + clp->cup = NULL; + free(clp->cuu1); + clp->cuu1 = NULL; + free(clp->rmso); + clp->rmso = NULL; + free(clp->smso); + clp->smso = NULL; } /* diff --git a/usr.bin/vi/common/cut.c b/usr.bin/vi/common/cut.c index 78eab40cd11..7ed134693a5 100644 --- a/usr.bin/vi/common/cut.c +++ b/usr.bin/vi/common/cut.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cut.c,v 1.16 2016/05/27 09:18:11 martijn Exp $ */ +/* $OpenBSD: cut.c,v 1.17 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -343,7 +343,6 @@ text_lfree(TEXTH *headp) void text_free(TEXT *tp) { - if (tp->lb != NULL) - free(tp->lb); + free(tp->lb); free(tp); } diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c index 619a80ff128..b78dd367847 100644 --- a/usr.bin/vi/common/exf.c +++ b/usr.bin/vi/common/exf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exf.c,v 1.44 2016/08/01 18:27:35 bentley Exp $ */ +/* $OpenBSD: exf.c,v 1.45 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -76,8 +76,7 @@ file_add(SCR *sp, CHAR_T *name) TAILQ_FOREACH_SAFE(frp, &gp->frefq, q, tfrp) { if (frp->name == NULL) { TAILQ_REMOVE(&gp->frefq, frp, q); - if (frp->name != NULL) - free(frp->name); + free(frp->name); free(frp); continue; } @@ -197,8 +196,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags) F_SET(frp, FR_TMPFILE); if ((frp->tname = strdup(tname)) == NULL || (frp->name == NULL && (frp->name = strdup(tname)) == NULL)) { - if (frp->tname != NULL) - free(frp->tname); + free(frp->tname); msgq(sp, M_SYSERR, NULL); (void)unlink(tname); goto err; @@ -410,10 +408,9 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags) return (0); -err: if (frp->name != NULL) { - free(frp->name); - frp->name = NULL; - } +err: + free(frp->name); + frp->name = NULL; if (frp->tname != NULL) { (void)unlink(frp->tname); free(frp->tname); @@ -422,10 +419,8 @@ err: if (frp->name != NULL) { oerr: if (F_ISSET(ep, F_RCV_ON)) (void)unlink(ep->rcv_path); - if (ep->rcv_path != NULL) { - free(ep->rcv_path); - ep->rcv_path = NULL; - } + free(ep->rcv_path); + ep->rcv_path = NULL; if (ep->db != NULL) (void)ep->db->close(ep->db); free(ep); @@ -659,8 +654,7 @@ file_end(SCR *sp, EXF *ep, int force) frp->tname = NULL; if (F_ISSET(frp, FR_TMPFILE)) { TAILQ_REMOVE(&sp->gp->frefq, frp, q); - if (frp->name != NULL) - free(frp->name); + free(frp->name); free(frp); } sp->frp = NULL; @@ -704,11 +698,8 @@ file_end(SCR *sp, EXF *ep, int force) (void)close(ep->fcntl_fd); if (ep->rcv_fd != -1) (void)close(ep->rcv_fd); - if (ep->rcv_path != NULL) - free(ep->rcv_path); - if (ep->rcv_mpath != NULL) - free(ep->rcv_mpath); - + free(ep->rcv_path); + free(ep->rcv_mpath); free(ep); return (0); } @@ -1358,8 +1349,7 @@ file_aw(SCR *sp, int flags) void set_alt_name(SCR *sp, char *name) { - if (sp->alt_name != NULL) - free(sp->alt_name); + free(sp->alt_name); if (name == NULL) sp->alt_name = NULL; else if ((sp->alt_name = strdup(name)) == NULL) diff --git a/usr.bin/vi/common/key.c b/usr.bin/vi/common/key.c index 08369cf400c..e3a85e2e7f7 100644 --- a/usr.bin/vi/common/key.c +++ b/usr.bin/vi/common/key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key.c,v 1.18 2016/05/27 09:18:11 martijn Exp $ */ +/* $OpenBSD: key.c,v 1.19 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -770,8 +770,7 @@ v_event_err(SCR *sp, EVENT *evp) } /* Free any allocated memory. */ - if (evp->e_asp != NULL) - free(evp->e_asp); + free(evp->e_asp); } /* diff --git a/usr.bin/vi/common/log.c b/usr.bin/vi/common/log.c index 83f79d0776c..22bb065d3a6 100644 --- a/usr.bin/vi/common/log.c +++ b/usr.bin/vi/common/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.11 2017/01/20 00:55:52 krw Exp $ */ +/* $OpenBSD: log.c,v 1.12 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -124,10 +124,8 @@ log_end(SCR *sp, EXF *ep) (void)(ep->log->close)(ep->log); ep->log = NULL; } - if (ep->l_lp != NULL) { - free(ep->l_lp); - ep->l_lp = NULL; - } + free(ep->l_lp); + ep->l_lp = NULL; ep->l_len = 0; ep->l_cursor.lno = 1; /* XXX Any valid recno. */ ep->l_cursor.cno = 0; diff --git a/usr.bin/vi/common/main.c b/usr.bin/vi/common/main.c index f20e4fde002..8b105d2a95d 100644 --- a/usr.bin/vi/common/main.c +++ b/usr.bin/vi/common/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.38 2016/05/27 09:18:11 martijn Exp $ */ +/* $OpenBSD: main.c,v 1.39 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -470,17 +470,14 @@ v_end(GS *gp) /* Free FREF's. */ while ((frp = TAILQ_FIRST(&gp->frefq))) { TAILQ_REMOVE(&gp->frefq, frp, q); - if (frp->name != NULL) - free(frp->name); - if (frp->tname != NULL) - free(frp->tname); + free(frp->name); + free(frp->tname); free(frp); } } /* Free key input queue. */ - if (gp->i_event != NULL) - free(gp->i_event); + free(gp->i_event); /* Free cut buffers. */ cut_close(gp); @@ -514,8 +511,7 @@ v_end(GS *gp) #if defined(DEBUG) || defined(PURIFY) /* Free any temporary space. */ - if (gp->tmp_bp != NULL) - free(gp->tmp_bp); + free(gp->tmp_bp); #if defined(DEBUG) /* Close debugging file descriptor. */ diff --git a/usr.bin/vi/common/options.c b/usr.bin/vi/common/options.c index a4cd43604b3..15c9e3b5999 100644 --- a/usr.bin/vi/common/options.c +++ b/usr.bin/vi/common/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.22 2016/08/01 18:27:35 bentley Exp $ */ +/* $OpenBSD: options.c,v 1.23 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -1129,9 +1129,7 @@ opts_free(SCR *sp) if (optlist[cnt].type != OPT_STR || F_ISSET(&optlist[cnt], OPT_GLOBAL)) continue; - if (O_STR(sp, cnt) != NULL) - free(O_STR(sp, cnt)); - if (O_D_STR(sp, cnt) != NULL) - free(O_D_STR(sp, cnt)); + free(O_STR(sp, cnt)); + free(O_D_STR(sp, cnt)); } } diff --git a/usr.bin/vi/common/screen.c b/usr.bin/vi/common/screen.c index 701b87c2c25..a9d0a9833e2 100644 --- a/usr.bin/vi/common/screen.c +++ b/usr.bin/vi/common/screen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen.c,v 1.13 2015/12/07 20:39:19 mmcc Exp $ */ +/* $OpenBSD: screen.c,v 1.14 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -176,22 +176,17 @@ screen_end(SCR *sp) text_lfree(&sp->tiq); /* Free alternate file name. */ - if (sp->alt_name != NULL) - free(sp->alt_name); + free(sp->alt_name); /* Free up search information. */ - if (sp->re != NULL) - free(sp->re); + free(sp->re); if (F_ISSET(sp, SC_RE_SEARCH)) regfree(&sp->re_c); - if (sp->subre != NULL) - free(sp->subre); + free(sp->subre); if (F_ISSET(sp, SC_RE_SUBST)) regfree(&sp->subre_c); - if (sp->repl != NULL) - free(sp->repl); - if (sp->newl != NULL) - free(sp->newl); + free(sp->repl); + free(sp->newl); /* Free all the options */ opts_free(sp); diff --git a/usr.bin/vi/common/seq.c b/usr.bin/vi/common/seq.c index 50cfda28a20..a9048a7e97c 100644 --- a/usr.bin/vi/common/seq.c +++ b/usr.bin/vi/common/seq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: seq.c,v 1.13 2016/05/27 09:18:11 martijn Exp $ */ +/* $OpenBSD: seq.c,v 1.14 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -58,8 +58,7 @@ seq_set(SCR *sp, CHAR_T *name, size_t nlen, CHAR_T *input, size_t ilen, sv_errno = errno; goto mem1; } - if (qp->output != NULL) - free(qp->output); + free(qp->output); qp->olen = olen; qp->output = p; return (0); @@ -95,8 +94,7 @@ seq_set(SCR *sp, CHAR_T *name, size_t nlen, CHAR_T *input, size_t ilen, } else if ((qp->output = v_strdup(sp, output, olen)) == NULL) { sv_errno = errno; free(qp->input); -mem3: if (qp->name != NULL) - free(qp->name); +mem3: free(qp->name); mem2: free(qp); mem1: errno = sv_errno; msgq(sp, M_SYSERR, NULL); @@ -148,11 +146,9 @@ int seq_mdel(SEQ *qp) { LIST_REMOVE(qp, q); - if (qp->name != NULL) - free(qp->name); + free(qp->name); free(qp->input); - if (qp->output != NULL) - free(qp->output); + free(qp->output); free(qp); return (0); } @@ -250,12 +246,9 @@ seq_close(GS *gp) SEQ *qp; while ((qp = LIST_FIRST(&gp->seqq)) != NULL) { - if (qp->name != NULL) - free(qp->name); - if (qp->input != NULL) - free(qp->input); - if (qp->output != NULL) - free(qp->output); + free(qp->name); + free(qp->input); + free(qp->output); LIST_REMOVE(qp, q); free(qp); } diff --git a/usr.bin/vi/ex/ex_bang.c b/usr.bin/vi/ex/ex_bang.c index 4486c9785bc..b056058ae3c 100644 --- a/usr.bin/vi/ex/ex_bang.c +++ b/usr.bin/vi/ex/ex_bang.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_bang.c,v 1.10 2016/01/06 22:29:38 millert Exp $ */ +/* $OpenBSD: ex_bang.c,v 1.11 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -63,8 +63,7 @@ ex_bang(SCR *sp, EXCMD *cmdp) /* Set the "last bang command" remembered value. */ exp = EXP(sp); - if (exp->lastbcomm != NULL) - free(exp->lastbcomm); + free(exp->lastbcomm); if ((exp->lastbcomm = strdup(ap->bp)) == NULL) { msgq(sp, M_SYSERR, NULL); return (1); diff --git a/usr.bin/vi/ex/ex_init.c b/usr.bin/vi/ex/ex_init.c index cfa2cccf599..8a7a3f787cb 100644 --- a/usr.bin/vi/ex/ex_init.c +++ b/usr.bin/vi/ex/ex_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_init.c,v 1.17 2016/01/06 22:28:52 millert Exp $ */ +/* $OpenBSD: ex_init.c,v 1.18 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -90,11 +90,8 @@ ex_screen_end(SCR *sp) if (argv_free(sp)) rval = 1; - if (exp->ibp != NULL) - free(exp->ibp); - - if (exp->lastbcomm != NULL) - free(exp->lastbcomm); + free(exp->ibp); + free(exp->lastbcomm); if (ex_tag_free(sp)) rval = 1; diff --git a/usr.bin/vi/ex/ex_read.c b/usr.bin/vi/ex/ex_read.c index 7457698060f..2d989508f7f 100644 --- a/usr.bin/vi/ex/ex_read.c +++ b/usr.bin/vi/ex/ex_read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_read.c,v 1.13 2016/05/27 09:18:12 martijn Exp $ */ +/* $OpenBSD: ex_read.c,v 1.14 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -111,8 +111,7 @@ ex_read(SCR *sp, EXCMD *cmdp) /* Set the last bang command. */ exp = EXP(sp); - if (exp->lastbcomm != NULL) - free(exp->lastbcomm); + free(exp->lastbcomm); if ((exp->lastbcomm = strdup(cmdp->argv[argc]->bp)) == NULL) { msgq(sp, M_SYSERR, NULL); diff --git a/usr.bin/vi/ex/ex_script.c b/usr.bin/vi/ex/ex_script.c index 2b842919753..83709d72212 100644 --- a/usr.bin/vi/ex/ex_script.c +++ b/usr.bin/vi/ex/ex_script.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_script.c,v 1.26 2016/05/27 09:18:12 martijn Exp $ */ +/* $OpenBSD: ex_script.c,v 1.27 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -569,8 +569,7 @@ sscr_setprompt(SCR *sp, char *buf, size_t len) SCRIPT *sc; sc = sp->script; - if (sc->sh_prompt) - free(sc->sh_prompt); + free(sc->sh_prompt); MALLOC(sp, sc->sh_prompt, len + 1); if (sc->sh_prompt == NULL) { sscr_end(sp); diff --git a/usr.bin/vi/ex/ex_subst.c b/usr.bin/vi/ex/ex_subst.c index a13ea3f6c53..64afb91e6a7 100644 --- a/usr.bin/vi/ex/ex_subst.c +++ b/usr.bin/vi/ex/ex_subst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_subst.c,v 1.29 2016/09/02 15:38:42 martijn Exp $ */ +/* $OpenBSD: ex_subst.c,v 1.30 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -187,8 +187,7 @@ subagain: return (ex_subagain(sp, cmdp)); if (p[0] == '\0' || p[0] == delim) { if (p[0] == delim) ++p; - if (sp->repl != NULL) - free(sp->repl); + free(sp->repl); sp->repl = NULL; sp->repl_len = 0; } else if (p[0] == '%' && (p[1] == '\0' || p[1] == delim)) @@ -227,8 +226,7 @@ tilde: ++p; ++len; } if ((sp->repl_len = len) != 0) { - if (sp->repl != NULL) - free(sp->repl); + free(sp->repl); if ((sp->repl = malloc(len)) == NULL) { msgq(sp, M_SYSERR, NULL); FREE_SPACE(sp, bp, blen); @@ -857,8 +855,7 @@ err: rval = 1; if (bp != NULL) FREE_SPACE(sp, bp, blen); - if (lb != NULL) - free(lb); + free(lb); return (rval); } @@ -917,10 +914,8 @@ re_compile(SCR *sp, char *ptrn, size_t plen, char **ptrnp, size_t *lenp, return (1); /* Discard previous pattern. */ - if (*ptrnp != NULL) { - free(*ptrnp); - *ptrnp = NULL; - } + free(*ptrnp); + *ptrnp = NULL; if (lenp != NULL) *lenp = plen; diff --git a/usr.bin/vi/ex/ex_tag.c b/usr.bin/vi/ex/ex_tag.c index 354ff76834c..435de679fe4 100644 --- a/usr.bin/vi/ex/ex_tag.c +++ b/usr.bin/vi/ex/ex_tag.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_tag.c,v 1.24 2016/01/06 22:28:52 millert Exp $ */ +/* $OpenBSD: ex_tag.c,v 1.25 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -102,8 +102,7 @@ ex_tag_push(SCR *sp, EXCMD *cmdp) exp = EXP(sp); switch (cmdp->argc) { case 1: - if (exp->tag_last != NULL) - free(exp->tag_last); + free(exp->tag_last); if ((exp->tag_last = strdup(cmdp->argv[0]->bp)) == NULL) { msgq(sp, M_SYSERR, NULL); @@ -208,10 +207,8 @@ ex_tag_push(SCR *sp, EXCMD *cmdp) err: alloc_err: - if (rtqp != NULL) - free(rtqp); - if (rtp != NULL) - free(rtp); + free(rtqp); + free(rtp); tagq_free(sp, tqp); return (1); } @@ -861,8 +858,7 @@ ex_tag_free(SCR *sp) tagq_free(sp, tqp); /* tagq_free removes tqp from queue. */ while ((tfp = TAILQ_FIRST(&exp->tagfq)) != NULL) tagf_free(sp, tfp); - if (exp->tag_last != NULL) - free(exp->tag_last); + free(exp->tag_last); return (0); } diff --git a/usr.bin/vi/vi/v_init.c b/usr.bin/vi/vi/v_init.c index a360a68ea88..4489fc538e2 100644 --- a/usr.bin/vi/vi/v_init.c +++ b/usr.bin/vi/vi/v_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_init.c,v 1.7 2015/12/07 20:39:19 mmcc Exp $ */ +/* $OpenBSD: v_init.c,v 1.8 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -81,16 +81,10 @@ v_screen_end(SCR *sp) if ((vip = VIP(sp)) == NULL) return (0); - if (vip->keyw != NULL) - free(vip->keyw); - if (vip->rep != NULL) - free(vip->rep); - if (vip->ps != NULL) - free(vip->ps); - - if (HMAP != NULL) - free(HMAP); - + free(vip->keyw); + free(vip->rep); + free(vip->ps); + free(HMAP); free(vip); sp->vi_private = NULL; diff --git a/usr.bin/vi/vi/v_paragraph.c b/usr.bin/vi/vi/v_paragraph.c index f2e7fd9b0b3..23efd73904f 100644 --- a/usr.bin/vi/vi/v_paragraph.c +++ b/usr.bin/vi/vi/v_paragraph.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_paragraph.c,v 1.8 2015/12/07 20:39:19 mmcc Exp $ */ +/* $OpenBSD: v_paragraph.c,v 1.9 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -326,8 +326,7 @@ v_buildps(SCR *sp, char *p_p, char *s_p) MALLOC_RET(sp, p, p_len + s_len + 1); vip = VIP(sp); - if (vip->ps != NULL) - free(vip->ps); + free(vip->ps); if (p_p != NULL) memmove(p, p_p, p_len + 1); diff --git a/usr.bin/vi/vi/vi.c b/usr.bin/vi/vi/vi.c index 77e224e949d..a8bfec9356d 100644 --- a/usr.bin/vi/vi/vi.c +++ b/usr.bin/vi/vi/vi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vi.c,v 1.20 2016/05/27 09:18:12 martijn Exp $ */ +/* $OpenBSD: vi.c,v 1.21 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -1001,10 +1001,8 @@ v_dtoh(SCR *sp) hidden = 0; gp = sp->gp; while ((tsp = TAILQ_FIRST(&gp->dq))) { - if (_HMAP(tsp) != NULL) { - free(_HMAP(tsp)); - _HMAP(tsp) = NULL; - } + free(_HMAP(tsp)); + _HMAP(tsp) = NULL; TAILQ_REMOVE(&gp->dq, tsp, q); TAILQ_INSERT_TAIL(&gp->hq, tsp, q); ++hidden; diff --git a/usr.bin/vi/vi/vs_msg.c b/usr.bin/vi/vi/vs_msg.c index 05b532f634c..09251c9d889 100644 --- a/usr.bin/vi/vi/vs_msg.c +++ b/usr.bin/vi/vi/vs_msg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vs_msg.c,v 1.19 2016/12/18 06:11:23 krw Exp $ */ +/* $OpenBSD: vs_msg.c,v 1.20 2017/04/18 01:45:35 deraadt Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -899,7 +899,6 @@ vs_msgsave(SCR *sp, mtype_t mt, char *p, size_t len) return; alloc_err: - if (mp_n != NULL) - free(mp_n); + free(mp_n); (void)fprintf(stderr, "%.*s\n", (int)len, p); } -- 2.20.1