Add efree() for consistency with emalloc() et al. Allows us to rely
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 29 Mar 2005 14:29:47 +0000 (14:29 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 29 Mar 2005 14:29:47 +0000 (14:29 +0000)
on C89 behavior (free(NULL) is valid) even on K&R.

19 files changed:
alias.c
alloc.c
check.c
defaults.c
find_path.c
gram.c
gram.y
interfaces.c
ldap.c
logging.c
match.c
mon_systrace.c
pwutil.c
redblack.c
sudo.c
sudo.h
toke.c
toke.l
visudo.c

diff --git a/alias.c b/alias.c
index 00d327bd02780e0031b7e50d81b4d68ec6c03516..e0a974cf4fe0a45dd1eb05042b6a343fcc702455 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -116,7 +116,7 @@ alias_add(name, type, members)
     a->type = type;
     a->first_member = members;
     if (rbinsert(aliases, a)) {
-       free(a);
+       efree(a);
        snprintf(errbuf, sizeof(errbuf), "Alias `%s' already defined", name);
        return(errbuf);
     }
@@ -156,11 +156,10 @@ alias_free(v)
 
     for (m = a->first_member; m != NULL; m = next) {
        next = m->next;
-       if (m->name != NULL)
-           free(m->name);
-       free(m);
+       efree(m->name);
+       efree(m);
     }
-    free(a);
+    efree(a);
 }
 
 /*
diff --git a/alloc.c b/alloc.c
index 4db6f2f249ad41431b259809a52002282bd49497..58123fb24ca37e9ec453db91b43f85dca6f8208c 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -211,3 +211,14 @@ evasprintf(ret, format, args)
        errorx(1, "unable to allocate memory");
     return(len);
 }
+
+/*
+ * Wrapper for free(3) so we can depend on C89 semantics.
+ */
+void
+efree(ptr)
+    VOID *ptr;
+{
+    if (ptr != NULL)
+       free(ptr);
+}
diff --git a/check.c b/check.c
index 6cff08d7acf865a21b2e8ebd6a9aed8620004d84..a117d74d228bfe4343884e5ffe9ee34dc92f368b 100644 (file)
--- a/check.c
+++ b/check.c
@@ -100,9 +100,8 @@ check_user(override)
     }
     if (status != TS_ERROR)
        update_timestamp(timestampdir, timestampfile);
-    free(timestampdir);
-    if (timestampfile)
-       free(timestampfile);
+    efree(timestampdir);
+    efree(timestampfile);
 }
 
 /*
@@ -551,7 +550,6 @@ remove_timestamp(remove)
        }
     }
 
-    free(timestampdir);
-    if (timestampfile)
-       free(timestampfile);
+    efree(timestampdir);
+    efree(timestampfile);
 }
index 0279a42c6896d4670c1ebd30874f436a39ba0abf..ea533089c0d3f48c3a61432c3b4b09d7ba8273ce 100644 (file)
@@ -362,10 +362,8 @@ init_defaults()
        for (def = sudo_defs_table; def->name; def++) {
            switch (def->type & T_MASK) {
                case T_STR:
-                   if (def->sd_un.str) {
-                       free(def->sd_un.str);
-                       def->sd_un.str = NULL;
-                   }
+                   efree(def->sd_un.str);
+                   def->sd_un.str = NULL;
                    break;
                case T_LIST:
                    list_op(NULL, 0, def, freeall);
@@ -621,8 +619,7 @@ store_str(val, def, op)
     int op;
 {
 
-    if (def->sd_un.str)
-       free(def->sd_un.str);
+    efree(def->sd_un.str);
     if (op == FALSE)
        def->sd_un.str = NULL;
     else
@@ -771,8 +768,8 @@ list_op(val, len, def, op)
        for (cur = def->sd_un.list; cur; ) {
            tmp = cur;
            cur = tmp->next;
-           free(tmp->value);
-           free(tmp);
+           efree(tmp->value);
+           efree(tmp);
        }
        def->sd_un.list = NULL;
        return;
@@ -789,8 +786,8 @@ list_op(val, len, def, op)
                prev->next = cur->next;
            else
                def->sd_un.list = cur->next;
-           free(cur->value);
-           free(cur);
+           efree(cur->value);
+           efree(cur);
            break;
        }
     }
index a40b594d41b2962e9568b45d4b5a15886a3b6d3a..b6f5f0aa48e8711fda4d8bf29d0fffe4248b5ff4 100644 (file)
@@ -120,7 +120,7 @@ find_path(infile, outfile, sbp, path)
        path = n + 1;
 
     } while (n);
-    free(origpath);
+    efree(origpath);
 
     /*
      * Check current dir if dot was in the PATH
diff --git a/gram.c b/gram.c
index 528b1d09e379dc48488aef01fe30692e1480081e..5c32568b88d81236af241b9ee348198e10151405 100644 (file)
--- a/gram.c
+++ b/gram.c
@@ -664,35 +664,31 @@ init_parser(path, quiet)
     for (us = userspecs; us != NULL; us = next) {
        for (m = us->user; m != NULL; m = next) {
            next = m->next;
-           if (m->name != NULL)
-               free(m->name);
-           free(m);
+           efree(m->name);
+           efree(m);
        }
        for (priv = us->privileges; priv != NULL; priv = next) {
            for (m = priv->hostlist; m != NULL; m = next) {
                next = m->next;
-               if (m->name != NULL)
-                   free(m->name);
-               free(m);
+               efree(m->name);
+               efree(m);
            }
            for (cs = priv->cmndlist; cs != NULL; cs = next) {
                for (m = cs->runaslist; m != NULL; m = next) {
                    next = m->next;
-                   if (m->name != NULL)
-                       free(m->name);
-                   free(m);
+                   efree(m->name);
+                   efree(m);
                }
-               if (cs->cmnd->name != NULL)
-                   free(cs->cmnd->name);
-               free(cs->cmnd);
+               efree(cs->cmnd->name);
+               efree(cs->cmnd);
                next = cs->next;
-               free(cs);
+               efree(cs);
            }
            next = priv->next;
-           free(priv);
+           efree(priv);
        }
        next = us->next;
-       free(us);
+       efree(us);
     }
     userspecs = NULL;
 
@@ -701,24 +697,21 @@ init_parser(path, quiet)
        if (d->binding != lastbinding) {
            for (m = d->binding; m != NULL; m = next) {
                next = m->next;
-               if (m->name != NULL)
-                   free(m->name);
-               free(m);
+               efree(m->name);
+               efree(m);
            }
            lastbinding = d->binding;
        }
        next = d->next;
-       free(d->var);
-       if (d->val != NULL)
-           free(d->val);
-       free(d);
+       efree(d->var);
+       efree(d->val);
+       efree(d);
     }
     defaults = NULL;
 
     init_aliases();
 
-    if (sudoers != NULL)
-       free(sudoers);
+    efree(sudoers);
     sudoers = estrdup(path);
 
     parse_error = FALSE;
@@ -726,7 +719,7 @@ init_parser(path, quiet)
     sudolineno = 1;
     verbose = !quiet;
 }
-#line 678 "gram.c"
+#line 671 "gram.c"
 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
 #if defined(__cplusplus) || defined(__STDC__)
 static int yygrowstack(void)
@@ -1371,7 +1364,7 @@ case 84:
                            NEW_MEMBER(yyval.member, yyvsp[0].string, WORD);
                        }
 break;
-#line 1323 "gram.c"
+#line 1316 "gram.c"
     }
     yyssp -= yym;
     yystate = *yyssp;
diff --git a/gram.y b/gram.y
index f2d3a1e4257946e148dbd874a76d132d124481ac..c2e3267b3f0ed1c6fe111abddcb08f201e963a11 100644 (file)
--- a/gram.y
+++ b/gram.y
@@ -562,35 +562,31 @@ init_parser(path, quiet)
     for (us = userspecs; us != NULL; us = next) {
        for (m = us->user; m != NULL; m = next) {
            next = m->next;
-           if (m->name != NULL)
-               free(m->name);
-           free(m);
+           efree(m->name);
+           efree(m);
        }
        for (priv = us->privileges; priv != NULL; priv = next) {
            for (m = priv->hostlist; m != NULL; m = next) {
                next = m->next;
-               if (m->name != NULL)
-                   free(m->name);
-               free(m);
+               efree(m->name);
+               efree(m);
            }
            for (cs = priv->cmndlist; cs != NULL; cs = next) {
                for (m = cs->runaslist; m != NULL; m = next) {
                    next = m->next;
-                   if (m->name != NULL)
-                       free(m->name);
-                   free(m);
+                   efree(m->name);
+                   efree(m);
                }
-               if (cs->cmnd->name != NULL)
-                   free(cs->cmnd->name);
-               free(cs->cmnd);
+               efree(cs->cmnd->name);
+               efree(cs->cmnd);
                next = cs->next;
-               free(cs);
+               efree(cs);
            }
            next = priv->next;
-           free(priv);
+           efree(priv);
        }
        next = us->next;
-       free(us);
+       efree(us);
     }
     userspecs = NULL;
 
@@ -599,24 +595,21 @@ init_parser(path, quiet)
        if (d->binding != lastbinding) {
            for (m = d->binding; m != NULL; m = next) {
                next = m->next;
-               if (m->name != NULL)
-                   free(m->name);
-               free(m);
+               efree(m->name);
+               efree(m);
            }
            lastbinding = d->binding;
        }
        next = d->next;
-       free(d->var);
-       if (d->val != NULL)
-           free(d->val);
-       free(d);
+       efree(d->var);
+       efree(d->val);
+       efree(d);
     }
     defaults = NULL;
 
     init_aliases();
 
-    if (sudoers != NULL)
-       free(sudoers);
+    efree(sudoers);
     sudoers = estrdup(path);
 
     parse_error = FALSE;
index 008fdb6bf688852aea92c5e4351c0772c9519629..4160207003cf9210e0b8ac6a25f172d7482d4775 100644 (file)
@@ -146,7 +146,7 @@ load_interfaces()
 #ifdef HAVE_FREEIFADDRS
     freeifaddrs(ifaddrs);
 #else
-    free(ifaddrs);
+    efree(ifaddrs);
 #endif
 }
 
@@ -189,7 +189,7 @@ load_interfaces()
 #else
        if (ioctl(sock, SIOCGIFCONF, (caddr_t) ifconf) < 0) {
 #endif /* _ISC */
-           free(ifconf_buf);
+           efree(ifconf_buf);
            (void) close(sock);
            return;
        }
@@ -279,9 +279,9 @@ load_interfaces()
            interfaces = (struct interface *) erealloc3(interfaces,
                num_interfaces, sizeof(struct interface));
        else
-           free(interfaces);
+           efree(interfaces);
     }
-    free(ifconf_buf);
+    efree(ifconf_buf);
     (void) close(sock);
 }
 
diff --git a/ldap.c b/ldap.c
index 0a1c9114b3e48d8e3d50a92a59b0c1aebdac6628..e4402411b7dbc32f0347ccb67618a4805c037b3c 100644 (file)
--- a/ldap.c
+++ b/ldap.c
@@ -260,8 +260,7 @@ sudo_ldap_check_command(ld, entry)
        /* Match against ALL ? */
        if (!strcasecmp(*p, "ALL")) {
            ret = TRUE;
-           if (safe_cmnd)
-               free(safe_cmnd);
+           efree(safe_cmnd);
            safe_cmnd = estrdup(user_cmnd);
            if (ldap_conf.debug > 1)
                printf(" MATCH!\n");
@@ -295,7 +294,7 @@ sudo_ldap_check_command(ld, entry)
            printf(" not\n");
        }
 
-       free(allowed_cmnd);     /* cleanup */
+       efree(allowed_cmnd);    /* cleanup */
     }
 
     if (v)
@@ -348,7 +347,7 @@ sudo_ldap_parse_options(ld, entry)
            /* case var Boolean True */
            set_default(var, NULL, TRUE);
        }
-       free(var);
+       efree(var);
     }
 
     if (v)
@@ -524,7 +523,7 @@ sudo_ldap_read_config()
        /* The following macros make the code much more readable */
 
 #define MATCH_S(x,y) if (!strcasecmp(keyword,x)) \
-    { if (y) free(y); y=estrdup(value); }
+    { efree(y); y=estrdup(value); }
 #define MATCH_I(x,y) if (!strcasecmp(keyword,x)) { y=atoi(value); }
 #define MATCH_B(x,y) if (!strcasecmp(keyword,x)) { y=_atobool(value); }
 
@@ -905,8 +904,7 @@ sudo_ldap_check(v, pwflag)
            if (ldap_conf.debug)
                printf("nothing found for '%s'\n", filt);
        }
-       if (filt)
-           free(filt);
+       efree(filt);
 
        /* parse each entry returned from this most recent search */
        entry = rc ? NULL : ldap_first_entry(ld, result);
index ea08887a871e5ec81978a589f41311686bd5c712..2ec1390baaccf043c13afefe2bc19960a101e6eb 100644 (file)
--- a/logging.c
+++ b/logging.c
@@ -189,12 +189,12 @@ do_logfile(msg)
        easprintf(&full_line, "Can't open log file: %s: %s",
            def_logfile, strerror(errno));
        send_mail(full_line);
-       free(full_line);
+       efree(full_line);
     } else if (!lock_file(fileno(fp), SUDO_LOCK)) {
        easprintf(&full_line, "Can't lock log file: %s: %s",
            def_logfile, strerror(errno));
        send_mail(full_line);
-       free(full_line);
+       efree(full_line);
     } else {
        if (def_loglinelen == 0) {
            /* Don't pretty-print long log file lines (hard to grep) */
@@ -259,7 +259,7 @@ do_logfile(msg)
                    beg = NULL;                 /* exit condition */
                }
            }
-           free(full_line);
+           efree(full_line);
        }
        (void) fflush(fp);
        (void) lock_file(fileno(fp), SUDO_UNLOCK);
@@ -330,7 +330,7 @@ log_auth(status, inform_user)
     if (def_logfile)
        do_logfile(logline);
 
-    free(logline);
+    efree(logline);
 }
 
 void
@@ -410,9 +410,9 @@ log_error(flags, fmt, va_alist)
     if (def_logfile)
        do_logfile(logline);
 
-    free(message);
+    efree(message);
     if (logline != message)
-       free(logline);
+       efree(logline);
 
     if (!ISSET(flags, NO_EXIT))
        exit(1);
diff --git a/match.c b/match.c
index b65ce1e202af8fe4cc1ebbef91606c71066e5c76..22428e300862edba2acdc5bf3848467a9573c734 100644 (file)
--- a/match.c
+++ b/match.c
@@ -293,8 +293,7 @@ command_matches(sudoers_cmnd, sudoers_args)
            (!user_args && sudoers_args && !strcmp("\"\"", sudoers_args)) ||
            (sudoers_args &&
             fnmatch(sudoers_args, user_args ? user_args : "", 0) == 0)) {
-           if (safe_cmnd)
-               free(safe_cmnd);
+           efree(safe_cmnd);
            safe_cmnd = estrdup(sudoers_cmnd);
            return(TRUE);
        } else
@@ -331,8 +330,7 @@ command_matches(sudoers_cmnd, sudoers_args)
            if (user_stat == NULL ||
                (user_stat->st_dev == sudoers_stat.st_dev &&
                user_stat->st_ino == sudoers_stat.st_ino)) {
-               if (safe_cmnd)
-                   free(safe_cmnd);
+               efree(safe_cmnd);
                safe_cmnd = estrdup(*ap);
                break;
            }
@@ -345,8 +343,7 @@ command_matches(sudoers_cmnd, sudoers_args)
            (!user_args && sudoers_args && !strcmp("\"\"", sudoers_args)) ||
            (sudoers_args &&
             fnmatch(sudoers_args, user_args ? user_args : "", 0) == 0)) {
-           if (safe_cmnd)
-               free(safe_cmnd);
+           efree(safe_cmnd);
            safe_cmnd = estrdup(user_cmnd);
            return(TRUE);
        } else
@@ -382,8 +379,7 @@ command_matches(sudoers_cmnd, sudoers_args)
                (!user_args && sudoers_args && !strcmp("\"\"", sudoers_args)) ||
                (sudoers_args &&
                 fnmatch(sudoers_args, user_args ? user_args : "", 0) == 0)) {
-               if (safe_cmnd)
-                   free(safe_cmnd);
+               efree(safe_cmnd);
                safe_cmnd = estrdup(sudoers_cmnd);
                return(TRUE);
            } else
@@ -411,8 +407,7 @@ command_matches(sudoers_cmnd, sudoers_args)
                continue;
            if (user_stat->st_dev == sudoers_stat.st_dev &&
                user_stat->st_ino == sudoers_stat.st_ino) {
-               if (safe_cmnd)
-                   free(safe_cmnd);
+               efree(safe_cmnd);
                safe_cmnd = estrdup(buf);
                break;
            }
@@ -581,7 +576,7 @@ netgr_matches(netgr, lhost, shost, user)
     if (domain == (char *) -1) {
        domain = (char *) emalloc(MAXHOSTNAMELEN);
        if (getdomainname(domain, MAXHOSTNAMELEN) == -1 || *domain == '\0') {
-           free(domain);
+           efree(domain);
            domain = NULL;
        }
     }
index 7e65f70d84fc50974e824f5173f5314e4f967c94..6c3802d991d2d33fb9c8fe5f802f00f03e82e8fb 100644 (file)
@@ -363,7 +363,7 @@ rm_child(pid)
                prev->next = cur->next;
            else
                children.first = cur->next;
-           free(cur);
+           efree(cur);
            break;
        }
        prev = cur;
index 213818d1d6503e135e29eea31ca70aa2083b56cc..2bc98b466354b59f4b2079feb3a03f9458f02fbd 100644 (file)
--- a/pwutil.c
+++ b/pwutil.c
@@ -290,11 +290,11 @@ sudo_fakepwuid(uid)
 
     /* Store by uid and by name, overwriting cached version. */
     if ((node = rbinsert(pwcache_byuid, pw)) != NULL) {
-       free(node->data);
+       efree(node->data);
        node->data = (VOID *) pw;
     }
     if ((node = rbinsert(pwcache_byname, pw)) != NULL) {
-       free(node->data);
+       efree(node->data);
        node->data = (VOID *) pw;
     }
     return(pw);
@@ -320,11 +320,11 @@ sudo_fakepwnam(user)
 
     /* Store by uid and by name, overwriting cached version. */
     if ((node = rbinsert(pwcache_byuid, pw)) != NULL) {
-       free(node->data);
+       efree(node->data);
        node->data = (VOID *) pw;
     }
     if ((node = rbinsert(pwcache_byname, pw)) != NULL) {
-       free(node->data);
+       efree(node->data);
        node->data = (VOID *) pw;
     }
     return(pw);
@@ -362,9 +362,9 @@ pw_free(v)
 
     if (pw->pw_passwd != NULL) {
        zero_bytes(pw->pw_passwd, strlen(pw->pw_passwd));
-       free(pw->pw_passwd);
+       efree(pw->pw_passwd);
     }
-    free(pw);
+    efree(pw);
 }
 
 /*
index 528cfcbec5a7f9cb1e54057a0da2a1cfd15871c2..f6b595a22736acca9f174efa26a5cc10d08993b5 100644 (file)
@@ -326,7 +326,7 @@ _rbdestroy(tree, node, destroy)
        _rbdestroy(tree, node->right, destroy);
        if (destroy != NULL)
            destroy(node->data);
-       free(node);
+       efree(node);
     }
 }
 
@@ -340,7 +340,7 @@ rbdestroy(tree, destroy)
     void (*destroy)__P((VOID *));
 {
     _rbdestroy(tree, rbfirst(tree), destroy);
-    free(tree);
+    efree(tree);
 }
 
 /*
@@ -379,7 +379,7 @@ rbdelete(tree, victim)
        else
            victim->parent->right = succ;
        data = victim->data;
-       free(victim);
+       efree(victim);
     } else {
        pred = victim->left == rbnil(tree) ? victim->right : victim->left;
        if (victim->parent == rbroot(tree)) {
@@ -394,7 +394,7 @@ rbdelete(tree, victim)
        if (victim->color == black)
            rbrepair(tree, pred);
        data = victim->data;
-       free(victim);
+       efree(victim);
     }
     return(data);
 }
diff --git a/sudo.c b/sudo.c
index 1216c1e248b1b8e0218a33d4c8890d703b590a94..0664e44276c4c4d0adcbf10713eff92e409eef4f 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -1091,8 +1091,8 @@ set_fqdn()
            "unable to lookup %s via gethostbyname()", user_host);
     } else {
        if (user_shost != user_host)
-           free(user_shost);
-       free(user_host);
+           efree(user_shost);
+       efree(user_host);
        user_host = estrdup(hp->h_name);
     }
     if ((p = strchr(user_host, '.'))) {
diff --git a/sudo.h b/sudo.h
index 52e54a16ec9dc8db95568c61f80a88a14ee6aae8..4769c4da61395a2a1336e622e3144af9f527e0ff 100644 (file)
--- a/sudo.h
+++ b/sudo.h
@@ -237,6 +237,7 @@ int easprintf               __P((char **, const char *, ...))
                            __printflike(2, 3);
 int evasprintf         __P((char **, const char *, va_list))
                            __printflike(2, 0);
+void efree             __P((VOID *));
 void dump_defaults     __P((void));
 void dump_auth_methods __P((void));
 void init_envtables    __P((void));
diff --git a/toke.c b/toke.c
index 7af1e5bb6d2a043fe0577aa1ddc683d0eaadde39..557960e2415f4e315aefde57d9746aa1fdf19835 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -2756,8 +2756,7 @@ fill_args(s, len, addspace)
            (char *) realloc(yylval.command.args, arg_size) :
            (char *) malloc(arg_size);
        if (p == NULL) {
-           if (yylval.command.args != NULL)
-               free(yylval.command.args);
+           efree(yylval.command.args);
            yyerror("unable to allocate memory");
            return(FALSE);
        } else
@@ -2833,7 +2832,7 @@ switch_buffer(path)
            fclose(YY_CURRENT_BUFFER->yy_input_file);
        yy_delete_buffer(YY_CURRENT_BUFFER);
        yy_switch_to_buffer(state[depth].bs);
-       free(sudoers);
+       efree(sudoers);
        sudoers = state[depth].path;
        sudolineno = state[depth].lineno;
        keepopen = FALSE;
diff --git a/toke.l b/toke.l
index 7abefb7246c944c8de5932a74aeb69db7a159cba..68c6bee29a152f48cdabb2ff6c6b11fe121b5c80 100644 (file)
--- a/toke.l
+++ b/toke.l
@@ -508,8 +508,7 @@ fill_args(s, len, addspace)
            (char *) realloc(yylval.command.args, arg_size) :
            (char *) malloc(arg_size);
        if (p == NULL) {
-           if (yylval.command.args != NULL)
-               free(yylval.command.args);
+           efree(yylval.command.args);
            yyerror("unable to allocate memory");
            return(FALSE);
        } else
@@ -585,7 +584,7 @@ switch_buffer(path)
            fclose(YY_CURRENT_BUFFER->yy_input_file);
        yy_delete_buffer(YY_CURRENT_BUFFER);
        yy_switch_to_buffer(state[depth].bs);
-       free(sudoers);
+       efree(sudoers);
        sudoers = state[depth].path;
        sudolineno = state[depth].lineno;
        keepopen = FALSE;
index fe79dbbff58ee923d3b3c5373a5129094fa67235..662b604b9761a8660b805fc80fe58b108eb7f842 100644 (file)
--- a/visudo.c
+++ b/visudo.c
@@ -489,7 +489,7 @@ install_sudoers(sp)
      * mv(1) in case sp->tpath and sp->path are on different file systems.
      */
     if (rename(sp->tpath, sp->path) == 0) {
-       free(sp->tpath);
+       efree(sp->tpath);
        sp->tpath = NULL;
     } else {
        if (errno == EXDEV) {
@@ -511,11 +511,11 @@ install_sudoers(sp)
                warningx("command failed: '%s %s %s', %s unchanged",
                    _PATH_MV, sp->tpath, sp->path, sp->path);
                (void) unlink(sp->tpath);
-               free(sp->tpath);
+               efree(sp->tpath);
                sp->tpath = NULL;
                return(FALSE);
            }
-           free(sp->tpath);
+           efree(sp->tpath);
            sp->tpath = NULL;
        } else {
            warning("error renaming %s, %s unchanged", sp->tpath, sp->path);
@@ -716,7 +716,7 @@ open_sudoers(path, keepopen)
        entry->tpath = NULL;
        if (entry->fd == -1) {
            warning("%s", entry->path);
-           free(entry);
+           efree(entry);
            return(NULL);
        }
        if (!lock_file(entry->fd, SUDO_TLOCK))
@@ -828,8 +828,7 @@ get_editor(args)
      * find one that exists, is regular, and is executable.
      */
     if (Editor == NULL || *Editor == '\0') {
-       if (EditorPath != NULL)
-           free(EditorPath);
+       efree(EditorPath);
        EditorPath = estrdup(def_editor);
        Editor = strtok(EditorPath, ":");
        do {